我试图使用rmagick 2.13.1和ruby 1.9.3p194重置图像中的EXIF方向字段,但它似乎没有保存。
img = ::Magick::Image::read(local_source_path).first
img.get_exif_by_entry()
=> [["ColorSpace", "1"],
["ExifImageLength", "2448"],
["ExifImageWidth", "3264"],
["ExifOffset", "38"],
["Orientation", "6"]]方向也可以通过这些属性来获得。
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",
"exif:Orientation"=>"6",
"jpeg:colorspace"=>"2",
"jpeg:sampling-factor"=>"2x2,1x1,1x1"}我尝试将定向属性设置为nil & save:
img['exif:Orientation'] = nil现在,
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"}看上去是对的。
img.write(local_dest_path)但是当我使用get_exif_by_entry时
img.get_exif_by_entry('Orientation')[0][1]我仍然得到6,而不是nil。
当我读取修改过的local_dest_path的书面文件时,我仍然得到"6“。
是否有我缺少的set_exif_by_entry函数?有什么想法吗?谢谢
发布于 2014-01-10 18:42:44
无法设置为nil,但在编写过程中我能够将其设置为1
img.write('local_dest_path') { self.orientation = ::Magick::TopLeftOrientation }常数UndefinedOrientation也不起作用。OrientationType中列出了其他可用的值。
https://stackoverflow.com/questions/21030378
复制相似问题