Skip to content

Instantly share code, notes, and snippets.

@sasa1977
sasa1977 / xmerl_demo.ex
Last active July 26, 2023 10:07
Simple xmerl usage demo in Elixir
defmodule XmlNode do
require Record
Record.defrecord :xmlAttribute, Record.extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
def from_string(xml_string, options \\ [quiet: true]) do
{doc, []} =
xml_string
|> :binary.bin_to_list
|> :xmerl_scan.string(options)
@felinx
felinx / gist:3021514
Created June 29, 2012 23:59
Handling exif info(orientation) losing after thumbnail a image with PIL
def _thumbnail_image(self, body, size):
try:
im = Image.open(StringIO(body))
# rotate image according rotation meta of this image
# for orientation in ExifTags.TAGS.keys():
# if ExifTags.TAGS[orientation] == 'Orientation' : break
orientation = 274 # get 274 through upper loop
try:
exif = im._getexif()