Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Michael Welles
RE: Version 1.1.0 Changes [ reply ]  
2006-09-02 23:32
Ryan: make sure you have bumped "max_allowed_packet" up in your mysql conf, and that you've got your column type to be a blob...

I had this same problem, Adding this to the [mysqld] stanza in my.cnf fixed:

max_allowed_packet = 1M

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-28 14:42
I finally solved my problem. I created a to_blob method in MiniMagick as such:

def to_blob
File.open(@path, "rb") do |image_file|
return image_file.read
end
end

And I used that instead of File.open(tpic.path).read in my model, and it did not truncate.

I have no idea why, but it worked.

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-27 12:18
Has anyone tried to do something like self.data = File.open(tpic.path).read (where tpic is a MiniMagick object) on Windows and had it work for them?

Have you done something else to write the object to an ActiveRecord field and had it work?

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-24 00:30
Doh, I just noticed that my fixes were encompassed in a couple of pending patches. Any reason why these haven't been applied? It would have saved me a couple of hours.

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 14:35
Here is the relevant part of where I am using MiniMagick in a model.

tpic = MiniMagick::Image::from_blob(picture_field.read)
logger.info(tpic.path)
tpic.resize("#{PictureFullWidth}x#{PictureFullHeight}")
logger.info(tpic.to_yaml)
self.data = File.open(tpic.path).read
logger.info(self.data)

At the end self.data just has the first several bytes of the picture file.

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 13:57
With the latest version the tests work (as long as there is no space in my path) but my application is still truncating the image when writing to the database. The same application works correctly in Linux.

By: Corey J
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 12:20
Anyone at rails conf? If so we could meet up and fix this changes in person and even talk about how to improve this thing more!

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 11:36
Ok, this one's better:

def [](value)
# Why do I go to the trouble of putting in newline chars? Because otherwise animated gifs screw everything up
case value.to_s
when "format"
run_command("identify", "-format", '"%m\n"', @path).split("\n")[0]
when "height"
run_command("identify", "-format", '"%h\n"', @path).split("\n")[0].to_i
when "width"
run_command("identify", "-format", '"%w\n"', @path).split("\n")[0].to_i
when "original_at"
# Get the EXIF original capture as a Time object
Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil
when /^EXIF\:/i
run_command('identify', '-format', "\"%[#{value}]\"", @path).chop
else
run_command('identify', '-format', "\"#{value}\"", @path)
end
end

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 11:11
Tests now passing on Windows and Mac. Change [] method to:

def [](value)
# Why do I go to the trouble of putting in newline chars? Because otherwise animated gifs screw everything up
case value.to_s
when "format"
run_command("identify", "-format", '"%m\n"', @path).split("\n")[0]
when "height"
run_command("identify", "-format", '"%h\\n"', @path).split("\n")[0].to_i
when "width"
run_command("identify", "-format", '"%w\\n"', @path).split("\n")[0].to_i
when "original_at"
# Get the EXIF original capture as a Time object
Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil
when /^EXIF\:/i
run_command('identify', '-format', "\"%[#{value}]\"", @path).chop
else
run_command('identify', '-format', "\"#{value}\"", @path)
end
end

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 11:04
Ok, now failing on my Mac. Looking into it.

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-23 11:01
Tests now passing on Windows. Can someone please check other platforms?

Change first test to this:

def test_image_from_blob
File.open(SIMPLE_IMAGE_PATH, "rb") do |f|
image = Image.from_blob(f.read)
end
end

and change [] method in mini_magick.rb to:

def [](value)
# Why do I go to the trouble of putting in newline chars? Because otherwise animated gifs screw everything up
case value.to_s
when "format"
run_command("identify", "-format", "%m\\n", @path).split("\n")[0]
when "height"
run_command("identify", "-format", "%h\\n", @path).split("\n")[0].to_i
when "width"
run_command("identify", "-format", "%w\\n", @path).split("\n")[0].to_i
when "original_at"
# Get the EXIF original capture as a Time object
Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil
when /^EXIF\:/i
run_command('identify', '-format', "\"%[#{value}]\"", @path).chop
else
run_command('identify', '-format', "\"#{value}\"", @path)
end


Cheers.

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-22 12:13
I tried that too and it didn't work. I'm running XP SP2 with ruby 1.8.2 (2004-12-25) (which is the only ruby that works correctly for me on Win32 with Rails. The test fails with the same message.


I am assuming that ruby can still read the file with /'s in the path instead of \'s even though I can't at the command prompt.

By: Andrew Peters
RE: Version 1.1.0 Changes [ reply ]  
2006-06-21 22:17
Yep, that was what I was seeing. I'm running Win2K3 and latest Ruby 1-click. Changing the write method as indicated in my other post (sorry about that btw, was late at night) fixed the problem.

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-21 15:12
But in my rails app the minimagick is actually writing part of the file (the first 50-400 bytes) to the table

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-21 14:52
At first the test wasn't working for me because of a quoting problem (it was trying to load 'C:\Documents'). I moved the project to a directory with no spaces and the test fails with:

.....identify: Negative or zero image size `C:/DOCUME~1/rick_wa/LOCALS~1/Temp/minimagic4460.3'.
./../lib/mini_magick.rb:121:in `run_command': ImageMagick command (identify C:/DOCUME~1/rick_wa/LOCALS~1/Temp/minimagic4460.3
) failed: Error Given 256 (MiniMagick::MiniMagickError)
from ./../lib/mini_magick.rb:42:in `initialize'

apparently "C:/Docume~1" doesn't work, but "C:\Docume~1" does

By: Cameron Pope
RE: Version 1.1.0 Changes [ reply ]  
2006-06-21 13:45
Hmmm, for me, the truncation issue got fixed by changing the write method of the mini_magick class to copy the file out of the tmp directory instead of streaming it from one place to the other. Windows doesn't seem to handle that well. Are the unit tests failing for you?

By: Ryan B
RE: Version 1.1.0 Changes [ reply ]  
2006-06-16 19:08
I tried the patch but I am still getting truncated images on Windows.

Which part of the patch fixes the truncation problem?

By: Cameron Pope
RE: Version 1.1.0 Changes [ reply ]  
2006-06-10 14:34
I have a windows machine that I use for development. I submitted a patch to the Rails plugin download that makes it, and all unit tests work for me. I've also tested it on Linux, so hopefully I haven't broken anything on the unix side.

By: Corey J
Version 1.1.0 Changes [ reply ]  
2006-04-12 00:58
There were a few major changes in this version...

1.) I moved all meta-information methods to Image::[]. So if you want to get the width of an image call image[:width], if you want the format call image[:format] and so on. Jon Bauman also added EXIF support which you can access by calling image["EXIF:ANY_EXIF_TAG"]

2.) If you want to change the format of in image you call the Image::format method. ImageMagick will also rename the files extention, be aware of that.

3.) I think I got all the binmode stuff in there to get this to work with windows. Thanks for all those windows guys out there that helped with this. I don't have a windows machine handy though, so if someone gets it working let me know.

Corey