Posted By

PixelMin on 10/22/08


Tagged

jpg file error ruby imagesize


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

webstic


Avoid "JPEG marker not found!" error


 / Published in: Ruby
 

If you get "JPEG marker not found!" error when you try to open an image file you must read it in binary mode.

  1. <%
  2.  
  3. my_file = File.open("image.jpg", "rb") {|f| f.read}
  4. img = ImageSize.new( my_file )
  5.  
  6.  
  7. # Testing: get img width with image_size lib.
  8.  
  9. img_witdh = img.get_width
  10.  
  11. %>

Report this snippet  

You need to login to post a comment.