# RMagick .psd to .jpg cannot load in browsers

**URL:** <https://www.ruby-forum.com/t/rmagick-psd-to-jpg-cannot-load-in-browsers/68052>\
**Category:** Ruby\
**Created:** [September 8, 2006, 7:34pm UTC](https://www.ruby-forum.com/t/rmagick-psd-to-jpg-cannot-load-in-browsers/68052 "2006-09-08T19:34:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![icvu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ba9def/32.png) [@icvu](https://www.ruby-forum.com/u/icvu)\
**Post date:** [September 8, 2006, 7:34pm UTC](https://www.ruby-forum.com/t/rmagick-psd-to-jpg-cannot-load-in-browsers/68052/1 "2006-09-08T19:34:43Z")

</div>

Hello Everyone, I am new to the group and I hope someone can help me.

I have been working on a project that requires me to convert images  
from one file format to the other. More specifically, from .psd to  
.jpg. I use RMagick to do the image resizing and format conversion. The  
conversion worked but the thumbnails, in .jpg, can only be viewed by my  
system (Win XP pro) applications such as Fireworks, Windows Picture and  
Fax Viewer, and Windows Explorer. The thumbnails cannot be viewed using  
any browser. They red “X” showed up as if the images are missing and  
the browsers do not seem to recognize their file format, which is  
supposed to be “.jpg”

Below is my code. I appreciate any help that could lead me toward a  
solution. Thanks in advance - icvu

def createThumbnail(data, imgDir)  
fileName = “#{data[1]} #{data[3]}.psd”  
imgName = fileName.reverse[4,fileName.length].reverse  
img = Magick::Image.read("#{imgDir}#{fileName}").first  
width, height = 60,60  
thumb = img.resize(width,height)  
thumbPath = “#{imgDir}thumb\”  
Dir.mkdir thumbPath unless File.exists? thumbPath  
imgThumb = “#{thumbPath}#{imgName}.jpg”  
thumb.write(imgThumb)  
end

---

<div class="post-metadata">

**Author:** ![icvu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/ba9def/32.png) [@icvu](https://www.ruby-forum.com/u/icvu)\
**Post date:** [September 8, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/rmagick-psd-to-jpg-cannot-load-in-browsers/68052/2 "2006-09-08T21:18:57Z")

</div>

It’s a good indication that either HTML headers are not set up  
properly or your code generates some error messages instead of  
binary .jpg content. Try to fetch the image url using curl. It’ll  
show you what is actually going on.

Mike D.  
[http://www.rubywizards.com](http://www.rubywizards.com)
