Users can upload images to my page. The problem is that when I try to convert them I get these errors:
gm convert: Improper image header
gm convert: Memory allocation failed
I can see them in Firefox/Safari/Chrome without a problem. Is there a way to "fix" these images command line. Some other utility to read and save them into a correct(non corrupt) format? Or maybe let graphicsmagick ignore these errors?
Related
I intended to read a DNG formatted image with the code rawpy.imread(path), however it returned me with a error message, saying unknown file: data corrupted at xxxxxxx (7-digit number).
Following this error, I found the program is still able to continue to run anyway, and the DNG image is not a flat one, since when visiting its property of raw_image_visible, it returned me with a ndarray of four channels. I have the lastest version of rawpy package (0.16.0) under Windows 10 environment.
I shared the photo via Google Drive. I have no idea how I can address this issue. Any kind of help is appreciated.
I am processing pdf files with imagemagick to images but this particular file is processed to some really gibberish stuff
To simplify stuff I am doing simple
convert file.pdf out.jpg
Just an idea is that it is mix of text pdf and image pdf and this could cause troubles. Can you help?
Pages of document which are in text are converted to this gibberish, last page which is actually scan is fine
this is the link to the original
file
EDIT: I found out that also files without combination of text and scan are causing issues, actually files which contain text data, not scanned image. So the question is how to setup imagemagick to convert pdf with pure text to image without getting this output
Problem was with ghostscript 9.22,
update to 9.23 helps
I've been using ImageMagick 6.9.0 for some time, and had setup some Railo scripts using it on a Windows Server 2008 R2 Standard Edition machine a while back. I know that they worked at the time. I just tried to run them on a new set of images now, but ImageMagick is failing on the very first command:
<cfexecute name="#Application.ImageMagickRoot#\identify.exe" variable="imgResult" timeout="60" arguments="-format ""%w|%h"" ""#attributes.infoFullPath#""" />
The error returned is:
identify.exe: RegistryKeyLookupFailed `CoderModulesPath' # error/module.c/GetMagickModulePath/662. identify.exe: no decode delegate for this image format `JPEG' # error/constitute.c/ReadImage/501.
I've never seen anything like this. So I checked and saw that there is a new version out, and downloaded IM 7.0.1. I tried running the above command again with no changes, but this time pointing to the 7.0.1 install folder. This resulted in a different, but similar, error:
identify.exe: unable to load module 'C:\ImageMagick-7.0.1-Q16\modules\coders\IM_MOD_RL_JPEG_.dll': The specified module could not be found. # error/module.c/OpenModule/1275. identify.exe: no decode delegate for this image format `JPEG' # error/constitute.c/ReadImage/505.
I looked in the directory in the error and there is a file named IM_MOD_RL_jpeg_.dll there.
The images that I'm trying to work with are all different, and I've cycled through 50 or so during testing. But all are between 4 and 10 megapixel photos exported from Photoshop CS5 Camera Raw to jpeg format. I've tried fiddling with the case of the drive letter and the file extension without success. A sample path to one of the images is:
c:\galleries_incoming\50\69\01 - Getting Ready\DSC_0001.JPG
I'm unsure what to try next. I tried running this command per an old message on the IM forum to get a list of my decode delegates:
convert -list configure
But IM tells me that configure is not a valid list option. In any case, it sounds like installing new decode delegates is something that requires a recompile, and I've just been relying on precompiled binaries (which I would assume would at least be able to read a jpeg).
I am facing an issue in generating thumbnails from a pdf file. I am using paperclip for this. Output of the identify command is below:
identify: Postscript delegate failed `filename.pdf': rKkP.cache # error/pdf.c/ReadPDFImage/638.
Any suggestions on this issue?
ImageMagick only process raster image files, it cannot natively read and interprete PDF or PostScript files.
It needs Ghostscript as its delegate to read and convert these formats to images.
Therefor you need to install Ghostscript, before the processing of PDF or PostScript files by ImageMagick and Paperclip can start to work.
How to validate corrupt image file while uploading using Rails
if the corrupted jpg or png file (or change the extension of any other type of file to jpg)
the system will have to show error during upload
I second Mike Trpcic's suggestion on using Paperclip, I have a screencast on the topic.
If you are using that and doing some graphic conversion (such as making thumbnails) you can look for PaperclipCommandLineError exception. I believe that is triggered if the conversion fails which would be the case if ImageMagick was not able to read the graphic (due to corruption or incorrect type).
If you rescue Paperclip::PaperclipCommandLineError you can present a nice error to the user.
You can check the MIME type to make sure that it's not file with a changed extension by using the mime-types library.
type = MIME::Types.type_for(your_file.original_filename).first
I'm not sure how that would work with corrupted/broken files though. Make sure to look into Paperclip for uploading files, as it's ridiculously easy to set up and use.