end
def img_element(fullpath)
- sizespec = `identify '#{fullpath}'` =~ / JPEG (\d+)x(\d+) / ? 'width="' + $1 + '" height="' + $2 + '"' : ''
+ if size = get_image_size(fullpath)
+ sizespec = 'width="${size[:x]}" height="${size[:y]}"'
+ else
+ sizespec = ''
+ end
return '<img src="' + File.basename(fullpath) + '" ' + sizespec + ' border="0"/>'
end
end
end
+ def get_image_size(fullpath)
+ if `identify '#{fullpath}'` =~ / JPEG (\d+)x(\d+) /
+ return { :x => $1, :y => $2 }
+ else
+ return nil
+ end
+ end
+
def gen_thumbnails(orig, xmldir, allow_background, dests)
if !dests.detect { |dest| !File.exists?(dest['filename']) }
return true
rotate = '-90'
end
rotate ||= '0'
+ #- remove rotate if image is obviously already in portrait (situation can come from gthumb)
+ size = get_image_size(orig)
+ if size && size[:x] < size[:y]
+ rotate = '0'
+ end
felem.add_attribute('rotate', rotate)
end
convert_options += "-rotate #{rotate} "