Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Ryan B
RE: mogrify -first [ reply ]  
2006-04-18 13:52
Yeah, the File.open method works well.

I think if you have a from_blob, then it would be nice to have a to_blob. It'll make my code look a little nicer ;-)

By: Corey J
RE: mogrify -first [ reply ]  
2006-04-18 13:48
MiniMagick is just a simple facade for ImageMagick.
In addition to the mogrify commands it has several built in class methods.

MiniMagick::Image.from_blob(data)
MiniMagick::Image.from_file(file_path)
MiniMagick::Image.new(file_path) # This allows you to edit the image inplace rather than making a copy like the above to methods do
MiniMagick::Image.write(output_path)

It doesn't have a to_blob method (I guess I should add that functionality). But you can emulate it. Assuming you have loaded a MiniMagick::Image file as image do this...

File.open(image.path, "rb") do |f|
blob_data = f.read
# Now you have the blob_data for your image, do whatever you would like with it.
end

By: Ryan B
RE: mogrify -first [ reply ]  
2006-04-18 13:41
I see that I can do:

File.open(tpic.path).read

That's not as pristine as I had hoped for, but it works. Sorry for being spastic.

By: Ryan B
RE: mogrify -first [ reply ]  
2006-04-18 13:33
I'm sorry, I was certainly posting too quickly. I was using RMagick code and didn't realize what minimagick was doing. The .first was from some RMagick example that I had found as well as the resize!

I just need a way to do something like a .read or .to_blob I don't see a mogrify command for that.

By: Corey J
RE: mogrify -first [ reply ]  
2006-04-18 13:24
MiniMagick just passes the commands directly to the mogrify program.
So if the command is not on this list http://www.imagemagick.org/script/mogrify.php it won't work in MiniMagick.

What does the -first argument do? Maybe there is another way around the problem.

By: Ryan B
RE: mogrify -first [ reply ]  
2006-04-18 13:22
I'm going to answer my own question and raise a new one. Removing the .first from the offending line removes that error, but then it fails trying to run this:

mogrify -resize! 200 200 /tmp/minimagic31232.0

-resize! is not a valid option

By: Ryan B
mogrify -first [ reply ]  
2006-04-18 13:15
I get this error:
mogrify -first /tmp/minimagic31232.0) failed: Error Given 256

when running this line:

tpic = MiniMagick::Image::from_blob(picture_field.read).first

-first doesn't seem to be a valid option to mogrify in either version 6.0.6 or 6.2.2

Is -first only supported in one of the later versions?