RMagick 文件大小为不同大小的图像提供奇怪的输出
当下面的代码片段令人惊讶地为原始图像和调整大小的图像提供相同的输出时。在 Ubuntu Jaunty 上使用 rmagick (2.12.2) 和 ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] 执行。
img = nil
File.open("~/rmagick/test/original.JPG", "r") { |f| img = f.read }
img = Magick::Image::from_blob(img).first
p img.filesize #=> 2875242, i.e 2.7 mb, similar when checked from file system
small = img.resize_to_fit(75, 75)
small.strip!
p small.filesize #=> 2875242 (again!), file system shows it's 2.7 kb
small.write("~/rmagick/test/s.jpg")
谁能指出问题吗?
谢谢
When the snippet below surprisingly giving the same output for the original and the resized image. Executed with rmagick (2.12.2) and ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] on Ubuntu Jaunty.
img = nil
File.open("~/rmagick/test/original.JPG", "r") { |f| img = f.read }
img = Magick::Image::from_blob(img).first
p img.filesize #=> 2875242, i.e 2.7 mb, similar when checked from file system
small = img.resize_to_fit(75, 75)
small.strip!
p small.filesize #=> 2875242 (again!), file system shows it's 2.7 kb
small.write("~/rmagick/test/s.jpg")
can anyone please point the problem?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 Magick::Image 文件大小属性仅在从文件读取图像或保存文件时更新。
It would appear that the Magick::Image filesize property is only updated when the image is read from a file, or the file is saved.