I'm trying to reset the Orientation EXIF field in my image using rmagick 2.13.1 and ruby 1.9.3p194, but it doesn't seem to save.
img = ::Magick::Image::read(local_source_path).first
img.get_exif_by_entry()
=> [["ColorSpace", "1"],
["ExifImageLength", "2448"],
["ExifImageWidth", "3264"],
["ExifOffset", "38"],
["Orientation", "6"]]
Orientation can also be acquired thru the properties
img.properties
outputs
{"date:create"=>"2014-01-08T17:26:10-08:00",
"date:modify"=>"2014-01-08T17:26:05-08:00",
"exif:ColorSpace"=>"1",
"exif:ExifImageLength"=>"2448",
"exif:ExifImageWidth"=>"3264",
"exif:ExifOffset"=>"38",
"exif:Orientation"=>"6",
"jpeg:colorspace"=>"2",
"jpeg:sampling-factor"=>"2x2,1x1,1x1"}
I try to set Orientation property to nil
& save:
img['exif:Orientation'] = nil
Now,
img.properties
=> {"date:create"=>"2014-01-08T17:26:10-08:00",
"date:modify"=>"2014-01-08T17:26:05-08:00",
"exif:ColorSpace"=>"1",
"exif:ExifImageLength"=>"2448",
"exif:ExifImageWidth"=>"3264",
"exif:ExifOffset"=>"38",
"jpeg:colorspace"=>"2",
"jpeg:sampling-factor"=>"2x2,1x1,1x1"}
which looks correct.
img.write(local_dest_path)
but when I use get_exif_by_entry
img.get_exif_by_entry('Orientation')[0][1]
I still get 6 & not nil
.
When I read the written file that was modified local_dest_path
, I still get "6".
Is there a set_exif_by_entry
function that I'm missing? Any ideas? Thanks
Couldn't set to nil
, but I was able to set it to 1 during the write
img.write('local_dest_path') { self.orientation = ::Magick::TopLeftOrientation }
The constant UndefinedOrientation
didn't work either. Other values available are listed in OrientationType.