I can’t for the life of me figure this out. Been banging my head on
this since the weekend, and can’t see what I’m doing wrong.
This code works:
image.resize(“640x480”)
image.write(path)
I run this and I get the resized file just fine.
This doesnt work at all:
width = 200
height = 100
dimensions = “#{width}x#{height}”
image.resize(dimensions)
image.write(path)
The second I variablize the parameters the whole thing freaks out with
this error:
ImageMagick command (mogrify -width “/tmp/minimagic6355.0”) failed:
Error Given 256
Anyone have any ideas? I like the idea of using mini_magick for the
smaller memory footprint, but much more of this and I need to go to
RMagick.
I know it’s not gonna help, but I’ve just tried your code and it works
perfectly…
And there is technically no reason why it should not!
Nauhaie N. wrote:
I know it’s not gonna help, but I’ve just tried your code and it works
perfectly…
And there is technically no reason why it should not!
Wow, this is really weird. If I hard code the dimensions it works fine.
I’m completely baffled by this one and have no idea where to even start
looking.
One clue might be the ruby code is inside a class in the lib directory.
I wonder if that might be causing it a problem.
Versions I’m running:
Debian 3.1
Ruby 1.8.4
Rails 1.1.6
mini_magick 1.1.2
imagemagick 6.2.4
Even if anyone has a guess as to where to start looking, I’d be hugely
appreciative!
I just ran into a similar problem myself when upgrading from an older
Mini Magick to version 1.2.0. I think, with the newer Mini_Magick
library, the style for retrieving attributes has been changed from:
image.height
image.width
to:
image[:height]
image[:width]
so this code:
if (image.width.to_f/image.height.to_f) >= (width.to_f/height.to_f)
should probably be changed to:
if (image[:width].to_f/image[:height].to_f) >= (width.to_f/height.to_f)
The giveaway for me was this line in my development log:
MiniMagick::MiniMagickError (ImageMagick command (mogrify -width
“/tmp/minimagic7060.0”) failed: Error Given 256):
Mini Magick was trying to use width as a mogrify option rather than
retrieving the image’s width.
Joe C. wrote:
Nauhaie N. wrote:
I know it’s not gonna help, but I’ve just tried your code and it works
perfectly…
And there is technically no reason why it should not!
Wow, this is really weird. If I hard code the dimensions it works fine.
I’m completely baffled by this one and have no idea where to even start
looking.
One clue might be the ruby code is inside a class in the lib directory.
I wonder if that might be causing it a problem.
Versions I’m running:
Debian 3.1
Ruby 1.8.4
Rails 1.1.6
mini_magick 1.1.2
imagemagick 6.2.4
Even if anyone has a guess as to where to start looking, I’d be hugely
appreciative!
Ok just for posterity, I found seemingly unrelated code that was the
problem. High up I had some code that I didn’t include that is causing
everything to fall apart:
if (image.width.to_f/image.height.to_f) >= (width.to_f/height.to_f)
#~ dimensions = “#{height}x#{width}”
#~ else
#~ dimensions = “#{width}x#{height}”
end
The second I comment out the if the code works, otherwise I get the
mogrify error. Now the question is why? I’m guessing something in the
evaluation is possible touching the image object?