Hi all,
I've been using G2 in work for about 3 months now and everything is great except when I try to upload PDFs, PSDs and some EPSs. I don't see any error, but with most of my PDFs no thumbnail is created, instead I see a thumbnail placeholder (if you will) with a link to a bigger preview of the pdf (bigger preview of the pdf shows same problem). I should mention at this point that I’m mostly interested in uploading and seeing previews for the PDFs, but the same problem happens with an EPS and a PSD file. I have both ImageMagic and GhostScript installed, and in fact when I test ImageMagick I see the following:
image/gif
image/jpeg
image/pjpeg
image/jp2
image/jpg2
image/jpx
image/png
image/tiff
image/svg+xml
image/bmp
application/pdf
application/postscript
application/photoshop
image/x-photo-cd
image/wmf
image/tga
image/jpeg-cmyk
image/tiff-cmyk
When I go to my Thumbnail Manager I see the following too (for ImageMagick Supported files):
application/pdf (pdf)
application/photoshop (psd)
application/postscript (eps ai ps)
image/bmp (bmp)
image/gif (gif)
image/jp2 (jpg2 jp2)
image/jpeg (jpg jpeg jpe)
image/jpeg-cmyk (jpgcmyk)
image/jpg2
image/jpx (jpx jpf)
image/pjpeg
image/png (png)
image/svg+xml (svg)
image/tga (tga)
image/tiff (tif tiff)
image/tiff-cmyk (tifcmyk)
image/wmf (wmf)
image/x-photo-cd (pcd)
image/x-portable-pixmap (ppm)
On my server I have tried the “Convert” command with great success (same PDF file as I was uploading), but only when converting a file in the C:\ drive. Here is where it gets a little interesting, my gallery setup is as such: I store my g2data on my E:\ drive and the gallery2 installation is on the C:\ drive, obviously I have granted enough access rights on the ‘g2data’ folder in the E:\ drive so that other file types are created (such as JPGs and GIFs), but, when I try the “convert” command from the prompt and the pdf is stored in the E:\ drive I get a file does not exists error.
I have tried a uploading different pdfs and managed to get a preview on a few of them, but not all, and can’t see why they would be different.
Since I’m NATed in I can’t give you guys access to my gallery, and I’m rather new to PHP so I’m not all sure about the debug feature in gallery. I can easily turn debug on, but I’m not sure what I need to look for, or at which stage (my guess is right after I upload the PDF, right?)
In any case, your help is greatly appreciated.
Here is my Gallery info:
Gallery version = 2.1-rc-1b core 1.0.30
PHP version = 5.1.2 cgi-fcgi
Webserver = Microsoft-IIS/6.0
Database = mysql 4.1.18-nt
Toolkits = Exif, ArchiveUpload, NetPBM, Gd, Dcraw, Thumbnail, ImageMagick
Operating system = Windows NT WIL-DEV-SERVER 5.2 build 3790
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1
If you guys need to see the debug info, I’ll be happy to comply.
Thanks again.
-Tom
Posts: 8601
If you turn on buffered debug output in config.php and then perform some operations you can look for "Executing" in the debug output. This will show the commands that are executed and all output from the commands.
Posts: 11
Hi mindless,
I did that already but could not see an error. I tried something new this morning, I converted the same PDF I uploaded through my dos prompt using the Convert command, and the JPG I got is interesting: I can open the JPG in my windows viewer or IrFanView, but not in Internet Explorer, and FireFox gives me the error: "The image cannot be displayed, because it contains errors." When I opened the image with IrFanView the Compression on it was JPEG, CMYK. I think that this might be causing the problem of most people not being able to see their PDF thumbnails because the JPG thumbnail's compression is also in CMYK which I guess the browsers do not support. I attached the same JPG that I converted, so you can see what I mean (try and look at the compression it uses) http://gallery.menalto.com/files/barbie_table_tents.jpg. I think that not all PDF get converted to a JPG that has compression JPEG and CMYK, it may be only PDFs with either vector graphics in them or ones that already include some CMYK image.
My question to you is, do you know of a way to force ImageMagick to convert a PDF to a JPG that has only JPEG compression? Also since I’m having the same problem with PSDs and EPSs I'll assume that the same problem is plaguing those formats as well, and the solution (if there is one) will work for those formats as well.
Thanks againf for your help.
Tom.
Posts: 8601
G2 with imagemagick module does have support for CMYK jpeg and tiff files... when converting from PDF/postscript it doesn't check colorspace.. I didn't even know these types could contain CMYK. I suppose you can file a feature request to add CMYK support for PDF/ps.. search for -colorspace in modules/imagemagick/classes/ImageMagickToolkit.class to see the convert params the module uses for CMYK jpeg/tiff.. you might be able to hack something together to make it work for you.
Posts: 11
I'm not sure what you mean by feature. It seems to me that ImageMagick looks at the PDF and creates a JPEG CMYK compressed thumbnail (if the PDF has CMYK in it, this was the default action when I used the convert command from dos prompt). What I’m really looking for is that all thumbnails that get created by ImageMagick all be just JPG with JPEG compression ones (no JPEG, CMYK compression in JPG) or else I will not be able to view them in my browser. So, really, what I need is for Gallery to force ImageMagick to create all thumbnails in a format that is supported by browsers. That's why I’m not sure what you mean by feature, seeing as it’s more of a bug.
I looked online and found a post here: http://redux.imagemagick.org/discussion-server/viewtopic.php?t=5242&sid=afa9b93e91f543d49bfcc758dbf07473 that mentions the same problem. The solution there seemed to be to create a PNG thumbnail whenever a PDF was uploaded.
My question now would be, if you know of a way to tell ImageMagick that a thumbnail of any uploaded file (any file that ImageMagick is supposed to handle for gallery) should be created as a JPG with only JPEG compression, if not, then I need to know how to get Gallery to use ImageMagick to create thumbnails of a PDF in a PNG format.
Thanks again for your help.
-Tom
Posts: 11
mindless
Please ignore the last comment, I get what you were saying now, and i've fixed it so that PDF's thumbnails get produced as JPG with RGB compression.
Thanks so much for the help. I hope that this bug gets corrected in a future version of Gallery.
Tom.
Posts: 4
TomNA: I'm having the same problem, can you plz post the corrected code?
Posts: 11
Hi ski3r,
The code you will need to edit is in the file modules/imagemagick/classes/ImageMagickToolkit.class
Line number 559 - 565 has the following code:
You will need to insert the following on the line 565 (moving "break;" to line 569):
Your changed code should now look like this: (from line 559-569)
Hope that helps.
Posts: 3
Hi, when I upload an .ai image or pdf image, it generates a thumbnail in .pdf, that i cant see either in Internet Explorer or FireFox. How can I do to generate a jpeg from this .ai in imagemagick, or to see the .pdf in my browser?
Posts: 11
tibor,
I'd suggest you forget about using that feature at this moment, i have, even tough i made it work. It is much simpler to use the Thumbnail manager and assign a default thumbnail to the PDF or AI files. But if you still need it to work, you can use my explanation above. i hope it works for you.
Posts: 3
It works, but sometimes when I try to upload an .ai doc, it falls in error:
Error Detail -
Error (ERROR_TOOLKIT_FAILURE)
* in modules/imagemagick/classes/ImageMagickToolkit.class at line 400 (GalleryCoreApi::error)
* in modules/imagemagick/classes/ImageMagickToolkit.class at line 52 (ImageMagickToolkit::_getImageDimensions)
* in modules/core/classes/GalleryDerivativeImage.class at line 179 (ImageMagickToolkit::getProperty)
* in modules/core/classes/helpers/GalleryDerivativeHelper_advanced.class at line 742 (GalleryDerivativeImage::rebuildCache)
* in modules/core/classes/GalleryCoreApi.class at line 956 (GalleryDerivativeHelper_advanced::rebuildCache)
* in modules/core/classes/helpers/GalleryDerivativeHelper_simple.class at line 66 (GalleryCoreApi::rebuildDerivativeCache)
* in modules/core/classes/GalleryCoreApi.class at line 942 (GalleryDerivativeHelper_simple::rebuildCacheIfNotCurrent)
* in modules/core/classes/helpers/GalleryDerivativeHelper_advanced.class at line 720 (GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent)
* in modules/core/classes/GalleryCoreApi.class at line 956 (GalleryDerivativeHelper_advanced::rebuildCache)
* in modules/core/classes/GalleryTheme.class at line 1487 (GalleryCoreApi::rebuildDerivativeCache)
* in themes/matrix/theme.inc at line 75 (GalleryTheme::loadCommonTemplateData)
* in modules/core/classes/GalleryTheme.class at line 916 (MatrixTheme::showAlbumPage)
* in modules/core/classes/GalleryView.class at line 325 (GalleryTheme::loadTemplate)
* in main.php at line 386 (GalleryView::doLoadTemplate)
* in main.php at line 87
* in main.php at line 80
System Information
Gallery version 2.1.1
PHP version 5.1.2-1.dotdeb.2 apache2handler
Webserver Apache/2.0.54 (Debian GNU/Linux) PHP/5.1.2-1.dotdeb.2
Database postgres7 7.4.7 3 8.1.3
Toolkits ImageMagick, SquareThumb, NetPBM, Gd
Operating system Linux avas 2.6.15.1 #1 SMP PREEMPT Sun Feb 26 17:08:42 UTC 2006 i686
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; hu; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2
Can you help me?
Posts: 8601
that means imagemagick isn't able to handle that file.
try using imagemagick from the commandline and see if you can make it work.
or turn on buffered debug output in config.php and look for the imagemagick errors (search for "Executing")