# Libjpeg collision when using RMagick (ImageMagick) and Image

**URL:** <https://www.ruby-forum.com/t/libjpeg-collision-when-using-rmagick-imagemagick-and-image/113297>\
**Category:** Rails\
**Created:** [August 29, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/libjpeg-collision-when-using-rmagick-imagemagick-and-image/113297 "2007-08-29T17:15:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b5ac83/32.png) [@erik](https://www.ruby-forum.com/u/erik)\
**Post date:** [August 29, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/libjpeg-collision-when-using-rmagick-imagemagick-and-image/113297/1 "2007-08-29T17:15:00Z")

</div>

I have a Rails app that uses BackgroundRB to process images. I’ve been  
using a class that uses RMagick for quite some time without any issues  
at all. I recently added a new class that processes images using  
image\_science instead of RMagick. After adding this new class and the  
image\_science gem RMagick throws the following error:

JPEG parameter struct mismatch: library thinks size is 428, caller  
expects 464 `’ - (Magick::ImageMagickError)

on this method: magick\_image = Magick::Image.from\_blob(image\_blob)

When I uninstall image\_science the class that uses RMagick ceases to  
throw the above error.

Here are my thoughts: image\_science uses FreeImage, which ships with  
its own version of libjpeg. When Rails boots up it loads the  
image\_science gem first, which loads FreeImage, which loads its own  
libjpeg. When RMagick gets loaded, is it possible that RMagick/  
ImageMagick will not use the libjpeg that is in /usr/lib and instead  
use the one that was loaded by image\_science/FreeImage?

This is of FC4 (i686 athlon i386 GNU/Linux) with Ruby 1.8.4 and the  
most recent versions of ImageMagick and RMagick.

Any help would be greatly appreciated!

Erik
