Why won't cmdwiz display my bmp image converted from png by imagemagick? - cmd

My batch script generates a bmp preview image using imagemagick and I want to display it in a cmd window using cmdwiz but it won't show up.
I tried generating a png then converting it to a bmp with "-type truecolor" but it didn't work. It did work when I converted the png using MS Paint though.

You need to establish the difference between the BMP that ImageMagick generates and the BMP that MS Paint generates to deduce what you need to tell ImageMagick to do differently. So, use:
magick identify -verbose IM.BMP > IM.TXT
magick identify -verbose MSPAINT.BMP > MSPAINT.TXT
Now use whatever tool Microsoft supplies to find the difference between IM.TXT and MSPAINT.TXT.
As an alternative, you can use exiftool, i.e.
exiftool IM.BMP
exiftool MSPAINT.BMP

Related

Converting TIFF to PDF with GraphicsMagick MediaBox / CropBox resolution

We are currently converting TIFF files to PDF using GraphicsMagick. The TIFF is coming from an eFAX and has a (pixel) resolution of 1728x2200.
If you do the conversion with tiff2pdf or just open it on Preview and convert export it to PDF, it is generated with a MediaBox value of 612x792 point, which is what is expected.
However graphics magick generates a MediaBox of 1728x4400 and a CropBox of 610x792. It all looks good if you open it on a PDF viewer because it's using the CropBox but if you're feeding it to GhostScript after, you don't get the Image on the full page but as a small square inside the document.
The lazy solutions would be to change for Tiff2PDF or add -dUseCropBox to our GhostScript command but I'd like to know what GraphicsMagick option should be used to have the PDF with the good MediaBox. It's like it doesn't understand that the resolution is in Pixels and not in Point. Hope somebody has insights

ImageMagick adds thick horizontal lines to PNGs extracted from PDF

Edit July 7, 2017: Downgrading to ImageMagick 6.9.5 solved this problem, which may be Cygwin-specific. I still don't know the underlying cause.
I need to extract data via OCR from images in PDF reports published by Chicago Public Schools. An example PDF is here (NB: this link downloads the file automatically rather than opening it in the browser). Here's a sample image (from PDF page 11, print page 8), extracted with pdfimages -png version 0.52.0 on Cygwin:
I'd like to crop each bar into its own file and extract the text with OCR. But when I try this with ImageMagick (version 7.0.4-5 Q16 x86_64 2017-01-25 according to convert -version), using the command convert chart.png -crop 320x600+0+0 bar.png, I get this image, with horizontal lines that interfere with OCR:
Running pdfimages to extract to PPM format first and then converting to PNG while cropping gives the same result, as does round-trip converting the extracted images to SVG format with ImageMagick's rsvg delegate, and fiddling with the PNG alpha channel changes the line's colors from gray to white or black but doesn't eliminate them. I've found a workaround of round-trip converting extracted images through JPG (introducing ringing artifacts, which I hope are irrelevant). But I don't see why I should have to do this. Incidentally, ImageMagick introduces the lines to PNGs even if I run a null conversion convert chart.png chart.png, which ought to leave the image unchanged:
I have found other complaints that PDF software adds horizontal lines to images, but none of them exactly matches this problem. A discussion thread mentions that versions of the PDF standard somehow differ in their treatment of alpha channels, but my knowledge of graphics is too poor understand the discussion fully; besides, my images get horizontal lines added after they're extracted from the PDF, because of something internal to ImageMagick. Can anyone shed some light on the causes of the grey lines?
Using the latest ImageMagick 7.0.6.0 Q16 Mac OS X, I get a good result. As mentioned above by Bonzo, the correct syntax for IM 7 is magick rather than convert. The use of convert reverts to IM 6. Also do not use magick convert either.
magick chart.png -crop 320x600+0+0 +repage bar.png
If this does not work for you, then there must have been a bug in your older version of IM 7. So you should then upgrade.
Note also the +repage is needed to remove the virtual canvas

Specifying image dimensions like Gimp in ImageMagick

I am editing an image in Gimp with dimensions and size specified as below.
How to use the same parameters in ImageMagick? (I tried something like below, but unable to get the desired output):
convert clipboard:image -crop 741x610+274+57 image.png
And how to copy this image back to clipboard?
I don't currently have a Windows system around (the clipboard: thingie works only on Windows -- for Mac and Linux there are no equivalents within ImageMagick).
But I think it should work like this:
convert clipboard: -crop 741x610+274+57 +repage clipboard:
However, I'm wondering why you use the clipboard for output at all? Why do you require to write back to the clipboard? (There may be other means to achieve what you want...)

Ghostscript - don't show objects with overprint set

I'm trying to convert preview pdfs uploaded by converting them to jpeg. Please can someone tell me how I can preview overprint? i.e. if a white object is set to overprint over a coloured background it shouldn't be shown - we only see the background.
/c 'C:\Program Files\gs\gs9.10\bin\gswin64c.exe' -o image%04d.jpg -sDEVICE=jpeg -dJPEGQ=60 -r150 -dSimulateOverprint=false -dUseCropBox uploaded.pdf
Also how can I output/list the created files?
Thanks
Overprint is only defined for CMYK inks, so you need to run to a device which support CMYK output. If you go to gray or RGB then the CMYK values are converted to RGB and will no longer overprint.
Try the tiff32nc device. Or jpegcmyk if you really want to use jpeg.

JPEG Shows in Firefox but Not IE8

I'm working on a Sidebar Gadget and cannot get my JPEGs to show up (PNGs work). When I try to open the file by itself in IE8 it doesn't work. Firefox, of course, can open it fine.
JPEG Details:
Dimensions: 1080X900
180 dpi
Bit depth 24
Color representation: uncalibrated
I've found some things talking about the images being compressed incorrectly (?) but I haven't been able to get it working...
Any clues?
IE8 drops support for CMYK JPEG and renders them as the infamous red X without so much as a warning.
If you have ImageMagick:
identify -verbose image.jpg
will show you the image colorspace. If it's CMYK, you can convert to RGB with:
convert broken.jpg -colorspace RGB fixed.jpg
If you need to do CMYK to RGB conversion on a whole batch of JPEG-images, this command may be helpful to you:
for i in *.jpg; do convert "$i" -colorspace RGB "$i"; done
PS: If you'd like to see what is going on, just add -verbose:
for i in *.jpg; do convert "$i" -colorspace RGB -verbose "$i"; done
I had a similar issue with IE8 not displaying two JPEG images. FF, Safari, Chrome all displayed them without complaint but IE acted as if the files were not there. I have no idea what was going on, but a quick image conversion to gif or png fixed the problem. Just another in a long line of confirmations that IE sucks.
Had similar problems with existing images, which will not show up in IE8.
Problem is, as converter42 says: CMYK-Images
Convert them to RGB colorspace and all is good
The Solution with the PNG is not the best, because PNG files can be MUUUCH larger than JPGS.
If you are using photoshop for creating the jpgs. Try the below.
Open the file and go to 'Image' menu
Go to Mode
Select RGB
Save and upload to server.
This should work.
Why are you dealing with the image at 180 dpi and not the 72dpi screen resolution? At screen resolution the image will be roughly double that size. Still, the size is manageable for any browser.
When creating a gadget, you should be using PNGs for all the elements of the gadgets. Are you having issues displaying JPEG photos?
Have you looked for the yellow bar at the top of IE that blocks certain suspicious content from being loaded (popups, activex, javascript, etc.)? If it appears, try telling it to "allow".
Lastly, what are you using to compress your images to JPEG?
EDIT: If you want to do batch conversion use the batch converter in photoshop or use the Actions panel to record the conversion process for a single image, then replay the action on an entire folder. Additionally, you can save this action to a "droplet" which is a small application containing the action that you can drop an image or folder on top to.
Alternatively, if you don't fell like learning Actions, XNView is an excellent image viewer and converter that supports something like 160 different image formats and can batch convert and batch rename huge lists of files.
I fixed this issue by opening the CMYK JPEG file in Windows Paint and then saving as a JPEG, which Paint encodes as RGB by default. Not a great solution because I'm sure that Paint's converter is not as robust as Photoshop's, but this can be a quick fix if the job needs to be done now and there's no access to the tools above.

Resources