Today, I hit a major roadblock: “JPEG datastream contains no image”. I turned to Google and found a solution.

Line 55 of tempfile.rb is:

@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)

Unfortunately, on Windows, this causes problems. If the file contains binary data (such as a JPEG datastream…), the fact that we open the file without the BINARY flag sometimes truncates the file content.

I patched my local Ruby 1.8.4 version to this:

@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL|File::BINARY, 0600)

The only change is I OR the File::BINARY flag to the mode parameter.

Now, I guess I should submit a Ruby enhancement request, no ? With failing test and all ? Sometimes I hate my Windows box…

1 Response to “RMagick and JPEG datastream contains no image”

  1. Ben Greenberg Says:

    Thanks! I know this is an old post, but I ran into this issue. It’s still not fixed in 1.8.6.

    In addition to your patch, I also had to change the File.open call in the #open method to: File.open(@tmpname, ‘rb+’) (line 77 in 1.8.6).

Leave a Reply

 

Search

A picture of me

I am François Beausoleil, a Ruby on Rails coder. During the day, I work on XLsuite. At night, I am interested many things. Read my biography

Tags

(3) (1) (0) (2) (1) (1) (2) (2) (1) (2) (1) (2) (1) (2) (1) (1) (1) (1) (2) (14) (1) (1) (1) (1) (2) (1) (1) (2) (0) (1) (2) (1) (3) (1) (1) (1) (1) (1) (1) (0) (3) (2) (1) (2) (2) (1) (3) (2) (8) (8) (9) (12) (1) (1) (3) (1) (1) (1) (1) (1) (1) (2) (2) (2) (1) (1) (4) (1) (3) (1) (2) (2) (2) (25) (2) (1) (1) (0) (1) (1) (1) (23) (25) (1) (1) (13) (1) (1) (2) (3) (1) (1) (4) (1) (2) (3) (0) (1) (7) (3) (1) (5) (5) (2) (2) (2) (4) (6) (7) (1) (0) (1) (1) (2) (2) (1) (4) (12) (2) (1) (2) (4) (1) (1) (1) (2) (8) (2) (3) (2) (2) (1) (3) (1) (1)

Links

Projects I work on

Categories

Archives