I can't convert image to monochrome bitmap with imagemagick - imagemagick

I'm trying to transform an image to monochrome bmp and its not working.
I tried writing:
magick.exe convert c:\users\asus\desktop\image.jpg -monochrome c:\image.bmp
and I got the following error
convert: UnableToOpenConfigureFile delegates.xml' # warning/configure.c/GetConfigureOptions/702.
convert: UnableToOpenModuleFile 'C:\Program Files\ImageMagick-7.0.10-Q16\modules\coders\IM_MOD_RL_JPEG_.dll': No such file or directory # warning/module.c/GetMagickModulePath/675.
convert: NoDecodeDelegateForThisImageFormatJPEG' # error/constitute.c/ReadImage/562.
convert: NoImagesDefined `c:\image.bmp' # error/convert.c/ConvertImageCommand/3282.
What am I doing wrong?

Related

Combine multiple command line commands into one single command (pipeline)

How do I combine the following ImageMagick command line commands into a single instruction:
convert -trim "C:\test\test.webp" -quality 95 "C:\test\testMaxNew.webp"
convert "C:\test\testMaxNew.webp" -resize 750x750 "C:\test\testMediumNew.webp"
convert "C:\test\testMediumNew.webp" -thumbnail 100x100^ "C:\test\testSmallNew.webp"
After some trial and error I came up with this:
convert -trim C:\test\test.webp -quality 95 -write mpr:XY +delete \( mpr:XY +write C:\test\testLargeNew.webp +delete \) \( mpr:XY -resize 750x750 +write C:\test\testMediumNew.webp +delete \) \( mpr:XY -resize 100x100^ -gravity center -extent 100x100 +write C:\test\testSmallNew.webp +delete \)
This does the trick but the following errors are reported in the command line prompt:
> convert: unable to open image '\(': No such file or directory #
> error/blob.c/OpenBlob/2695. convert: no decode delegate for this image
> format `' # error/constitute.c/ReadImage/508. convert: unable to open
> image '\)': No such file or directory # error/blob.c/OpenBlob/2695.
> convert: no decode delegate for this image format `' #
> error/constitute.c/ReadImage/508. convert: unable to open image '\(':
> No such file or directory # error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' #
> error/constitute.c/ReadImage/508. convert: unable to open image '\)':
> No such file or directory # error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' #
> error/constitute.c/ReadImage/508. convert: unable to open image '\(':
> No such file or directory # error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' #
> error/constitute.c/ReadImage/508. convert: no images defined `\)' #
> error/convert.c/ConvertImageCommand/3235.
Can someone explain why I am getting these errors and if my code is correct?
The reason I am trying to combine multiple commands is to minimize processing time.
Version: ImageMagick 7.0.2-0 Q16 x64 on Windows 10
These should do what you want.
Best to read the input right after convert.
I am not sure why you need to resize and thumbnail.
So in Imagemagick try one of the following:
convert "C:\test\test.webp" -trim +repage -quality 95 -resize 750x750 -thumbnail 100x100^ "C:\test\testSmallNew.webp"
or just
convert "C:\test\test.webp" -trim +repage -quality 95 -thumbnail 100x100^ "C:\test\testSmallNew.webp"
Just adding an answer to clarify a couple of things that are not a good fit for comments.
You already have some excellent advice from Fred (#fmw42) as regards reading your input image immediately after convert because that way your command will continue to work when you upgrade to ImageMagick v7 which has already been available a couple of years.
You have added a command that works to your question, but that is a bit clumsy inasmuch as it creates an MPR which you don't need and also creates and destroys images unnecessarily - adding to system load which is undesirable if you have many images to process. I think you can see the following is simpler to understand and maintain, makes fewer copies and deletes and demands on memory, and should achieve the same effect as your command:
convert INPUT.webp -trim +repage -gravity center -quality 95 ^
+write LARGE.webp ^
-resize 350x350 +write MEDIUM.webp ^
-resize 100x100^ -extent 100x100 SMALL.webp

When I try to do a batch magick convert -flatten command on a directory, it fails

I'm, trying to flatten a whole directory of .png images to have a white background.
The following command works on a single file:
magick convert -flatten "c:\Users\LibrarySurface2\OneDrive\Pictures\2016-08-09 archive of coworking space feedback\20151214 115702.png" "c:\Users\LibrarySurface2\OneDrive\Pictures\2016-08-09 archive of coworking space feedback\20151214 115702-white.png"
...however when I try to run it against the whole directory (1300 or so images) using the following command:
magick convert -flatten *.png *-w.png
It fails out with a bunch of these, and then stops running because of "too many exceptions" any thoughts on what could be causing this?
convert: Expected 3949 bytes; found 2684 bytes .\20160426 114948.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception.\20160426 114948.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image .\20160426 114948.png' # error/png.c/ReadPNGImage/4029.
convert: Expected 4585 bytes; found 929 bytes.\20160429 145040.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception .\20160429 145040.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image.\20160429 145040.png' # error/png.c/ReadPNGImage/4029.
convert: Expected 8192 bytes; found 8037 bytes .\20160504 165938.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception.\20160504 165938.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image `.\20160504 165938.png' # error/png.c/ReadPNGImage/4029.
Make a backup first, then use mogrify instead:
mogrify -flatten *.png
Explanation: In general, use the convert command when you want one output file and mogrify when you want multiple output files.

ImageMagick error: no decode delegate

I'm trying to convert an image with imagemagick, but I'm getting this error:
convert: no decode delegate for this image format
`/tmp/magick-XXITXcTr' # constitute.c/ReadImage/503.
I'm doing this:
convert http://images.icecat.biz/img/norm/high/12003462-2669.jpg -bordercolor white -border 1x1 -matte -fill none -fuzz 7% -draw 'matte 1,1 floodfill' -shave 1x1 /myimagefolder/iphone.png
I have the following delegates:
DELEGATES bzlib fontconfig freetype gs jpeg jng jp2 lcms openexr
png rsvg tiff x11 xml wmf zlib
Anyone knows what the problem is?
This is happening because the image you are trying to download no longer exists and returns a 404. ImageMagick creates a temporary file before it downloads the image. But this file will remain empty because the download fails for this image. ImageMagick will try to read the image but fails because it cannot handle empty files.

ImageMagick convert from GRAY to TIFF using stdin

I have a file I'm saving in raw GRAY format, which then gets converted to tiff. Running the command as follows works:
convert -size 1024X1024 -depth 16 -endian MSB imgTemp.gray /tmp/bla.tiff
but changing to use stdin as the input doesn't:
cat imgTemp.gray | convert -size 1024x1024 -depth 16 -endian MSB -:gray /tmp/bla.tiff
I get the following error:
convert: no decode delegate for this image format gray' # error/constitute.c/ReadImage/532.
convert: missing an image filename/tmp/bla.tiff' # error/convert.c/ConvertImageCommand/3011.
The question is why?
You just have the STDIN and format flipped. "-:gray" should be "gray:-"
cat imageTemp.gray |
convert -size 1024x1024 \
-depth 14 \
-endian MSB gray:- /tmp/bla.tiff
To answer why this is happening. We can run your previous command with a -verbose switch.
cat imgTemp.gray | \
convert -verbose \
-size 1024x1024 \
-depth 16 \
-endian MSB -:gray /tmp/bla.tiff
This will give use an additional line of information that explains what ImageMagick is trying to do
convert: unable to open image `gray':
No such file or directory # error/blob.c/OpenBlob/2638.
convert: no decode delegate for this image format
`gray' # error/constitute.c/ReadImage/550.
convert: no images defined `bla.tiff' # error/convert.c/ConvertImageCommand/3078.
Convert command becomes confused with -:gray and tries to open a blob file entitled "gray", and eventually attempts to open "bla.tiff" as a source image. Both of them non-existing on the filesystem.

Identity command is failing for pdf and txt files

For some reason tests fail for pdf and txt files, however using the app through the browser I am able to upload both of these formats.
Any ideas for how to fix this?
Error that is thrown:
Image /tmp/stream20110105-27382-hc9w7l-0.pdf is not recognized by the 'identify' command..
Output of identify command calls:
# png file works
[chris#chris-archlinux test]$ identify fixtures/files/brown-1920x1080.png fixtures/files/brown-1920x1080.png PNG 1920x1080 1920x1080+0+0 8-bit DirectClass 257KB 0.000u 0:00.000
# jpg works
[chris#chris-archlinux test]$ identify fixtures/files/avatar.jpg fixtures/files/avatar.jpg JPEG 478x478 478x478+0+0 8-bit DirectClass 72KB 0.000u 0:00.000
# txt fails
[chris#chris-archlinux test]$ identify fixtures/files/file_2.txt identify: unable to read font `/usr/share/fonts/Type1/n019003l.pfb' # error/annotate.c/RenderFreetype/1059. identify: no decode delegate for this image format `/tmp/magick-XXKkKcoe' # error/constitute.c/ReadImage/532. identify: unable to get type metrics `fixtures/files/file_2.txt' # error/txt.c/ReadTEXTImage/256.
# pdf fails
[chris#chris-archlinux test]$ identify fixtures/files/file.pdf identify: no decode delegate for this image format `fixtures/files/file.pdf' # error/constitute.c/ReadImage/532.
Are you using Paperclip for attachments? If so, read on. Otherwise ignore...
I remember having a similar error when trying to use Paperclip. It was because my executable path wasn't setup right. Assuming you have all the imagemagick binaries installed, try adding the following to an initialize or environment file:
My OS X env uses:
Paperclip.options[:command_path] = "/usr/local/bin"
Linux env uses:
Paperclip.options[:command_path] = "/usr/bin"
try:
pacman -S ghostscript
As root. That ought to fix your pdf problem, at least.

Resources