I have a 32 bit single channel EXR image that I want to crop using ImageMagick, the problem is after I crop it it got saved into 32 bit 3 channel image by ImageMagick.
Below are the attempts that I tried that didn't work
mogrify -crop 200x100+238+200 test.exr -colorspace Y
This returns error mogrify: unrecognized image colorspace `Y'.
mogrify -crop 200x100+238+200 test.exr -channel Y
This returns 32 bit 3 channel image.
mogrify -crop 200x100+238+200 test.exr -separate
This returns 8 bit 1 channel image.
I am on Ubuntu 16.04 and my version of ImageMagick is 6.9.6-4 Q32 x86_64.
How can I make ImageMagick to save my EXR file with the original single channel 32 bit format?
One expert from the ImageMagick forum actually posted an answer which works perfectly for me.
convert test.exr -crop 200x100+238+200 +repage -define exr:color-type=Y result.exr
Related
I want to use imagemagick to crop an image.
However, imagemagick will be receiving the image data to crop through a pipe before it:
exiftool -b -RawThermalImage image1.jpg | convert .....-crop.....
I am not sure what to put in the ".....-crop.....", to crop the image data received to a specific area. Please guide.
Usually, after convert, an image is specified for cropping like:
convert rose: -crop 1x1+3+3 cropped.gif
But, in this case, I am confused as to how to complete this command given that the image is coming in from the pipe.
ImageLink:
https://drive.google.com/file/d/14h3z0yFK_9_f2puzbhLUm3D50MDMMnu2/view?usp=sharing
Updated Answer
It transpires that the problem was caused by inadvertently using GraphicsMagick rather than ImageMagick.
Original Answer
You should be able to use a dash - to refer to the stdin if that stream has a well-known magic number (signature) at the start:
exiftool -b -RawThermalImage image1.jpg | convert - -crop ... result.jpg
If the stream is raw, or doesn't have a known magic number/signature, you will need to give ImageMagick a hint, so if it is raw greyscale 8-bit data with shape 640x480, use:
exiftool -b -RawThermalImage image1.jpg | convert -size 640x480 -depth 8 GRAY:- -crop ... result.jpg
If it's RGB888 data with size 80x80, use:
exiftool -b -RawThermalImage image1.jpg | convert -depth 8 -size 80x80 RGB:- -crop ... result.jpg
I'm trying to convrt RAW image to PNG with Imagemagick.
Imagemagick version I'm using is 6.7.8-9.
The RAW image want to convert is:
https://drive.google.com/file/d/1V1c-ytjkLaCM3KbAc6Yxj2nfWzNkYohc/view?usp=sharing
My client gave me a big RAW image which contains more than 1000 RAW images and it is generated from Dicom. Firstly, I cropped just one image with the command (crop command did not work somehow, so used convert):
convert -size 512x512 -depth 16 UYVY:original.raw result.raw
result.raw appears good on ImageJ.
Now, I have no idea how to get PNG from it.
I tested some commands:
This one generated a very bad quality:
convert -size 512x512 -depth 16 gray:result.raw result.png
This one gets green-ish image:
convert -size 512x512 -depth 16 uyvy:result.raw result.png
If I open result.raw on ImageJ and save as PNG, it works perfectly.
I got an answer from Imagemagick community. Firstly, below code to get the first image from the original raw was wrong.
convert -size 512x512 -depth 16 UYVY:original.raw result.raw
This is the correct way (512*512*2bytes=524228)
head --bytes 524288 original.raw >firstimage.raw
Then convert to PNG:
magick -size 512x512 -depth 16 gray:firstimage.raw -evaluate AddModulus 50% -auto-level x.png
Here is another way in ImageMagick that I think is more intuitive to your signed raw data. I simply specify the data is signed using -define quantum-format=signed. Then stretch the result to full dynamic range using -auto-level.
convert -size 512x512 -depth 16 -define quantum:format=signed gray:original.raw -auto-level result.png
If using ImageMagick 7, then replace convert with magick.
I am converting many 3D textures with imagemagick for a video game. My source files are png, my target files are png, too. But I notice that whenever the alpha channel drops to 0.0 my color information are gone (and I need them). I just want to scale all channels as they are. I guess there is a small switch that fixes that problem, but the deadline is near and I cannot find anything about that.
Simple command to reproduce this:
convert source-with-alpha.png -scale 2014 target.png (I also tried -resize and it also didn't work).
Doing just convert source-with-alpha.png target.png works fine though (but has no scaledown).
Thank you for your help.
I guess ImageMagick is trying to optimise something but not sure what/why. Maybe the idea is that if something is transparent you can't see it, so we might as well make it black so it compresses well.
Anyway, try separating the channels so they are all just treated as independent channels, then resizing and recombining:
convert input.png -channel RGBA -separate -resize XxY -combine result.png
I am not sure I understand your problem. I have no issue resizing a transparent PNG image with ImageMagick 6.9.10.28 Q16 Mac OSX with libpng 1.6.36. Perhaps you need to upgrade one or both.
Image:
Make white into transparent:
convert logo.png -transparent white logot.png
Resize it:
convert logot.png -resize 25% logot_small.png
I tried Mark Setchell answer with two different versions of Windows imagemagick but I still have this issue.
RGB becomes 0 if alpha is 0 when resizing.
A workaround was to add alpha a little bit so it becomes non-zero:
magic.exe input.tga -channel a -evaluate add 0.2% -channel RGBA -separate -filter Quadratic -resize -resize XxY! -combine result.tga
or also (same result)
magick.exe ( input.tga -alpha off -filter Quadratic -resize XxY! ) ( input.tga -filter Quadratic -resize XxY! -alpha extract -evaluate add 0.2% ) -compose Copy_Alpha -composite result.tga
("-filter Quadratic" is optional)
Post one of your tga files so we can test with it. What is your ImageMagick version? There should be no need for any switch. This works fine for me on IM 6.9.10.65 Q16 Mac OSX.
Make a transparent TGA:
convert logo: -transparent white logo.tga
transparent tga image
Resize by 50%
convert logo.tga -resize 50% logo2.tga
resized transparent tga image
I want to watermark an image, so I used compose multiply, but for some reason it doesn't work as expected.
The command:
magick image.jpg over.png -compose multiply -resize 2048x2048 -gravity center -quality 65 -strip -composite out.jpg
The over.png get inverted first and then applied??
If use the same command with and older version of Imagemagick (x32 6.7.6-1 2012-03-17 Q16) I get the expected results.
This was tested with x64 ImageMagick 7.0.5 Q16 under Windows 10.
Ah it seems I can't post all the images.
After a lot of research, turns out it's an artifact of one of the images being a JPEG in CMYK colorspace.
Very weird, but there you go.
Adding '-profile sRGB.icc' to the line should take care of it.
FYI your syntax is not proper. You have separated -compose multiply and -composite with -resize. You should do it this way with nothing between them.
magick image.jpg over.png -gravity center -compose multiply -composite -resize 2048x2048 -strip -quality 65 out.jpg
As you said there will be issues if your input JPG is CMYK and your png will always be sRGB. So you do need to convert the CMYK to sRGB before processing.
I was able to convert my EXR image to a PNG using the techniques outlined in Image conversion from IFF and EXR formats to JPEG format .
convert 0007.exr /tmp/0007.png
Unfortunately the PNG looks quite dim.
What should I add to the imagemagick convert command line to increase the brightness?
Starting with this:
You could try -auto-gamma:
convert start.jpg -auto-gamma result.jpg
If the -auto-gamma overcooks the image for your liking, you could apply a percentage of it. So, here I clone the original image and apply auto-gamma to the clone but then only blend 80% back into the original because I feel auto-gamma overdoes it:
convert start.jpg \( +clone -auto-gamma \) \
-define compose:args=80 -compose blend -composite result.jpg
Or, another option, you could experiment with your particular images and maybe try using -modulate for the brightness, where 100% means "do nothing", so numbers over 100 increase the brightness:
convert start.jpg -define modulate:colorspace=LCHuv -modulate 160 result.jpg
You can try -auto-level, which will take the minimal value and the maximal value of your picture and then stretches the values to the full range of values:
convert input.exr -auto-level output.jpg
Note that if you picture was too bright and this does not help, then it might be that your image is stored with 32 Bit, while ImageMagick is working with 16 Bit and no HDRI support. 32 Bit input is supported if convert --version
either show Q32 as part of the version string or lists HDRI under features.
Depending on your operating system you might be able to install another variant of ImageMagick. For example, for Debian Buster we can use sudo apt list imagemagick* to see that the package imagemagick-6.q16hdri is available. Installing this package provides convert-im6.q16hdri, which allows reading 32 Bit EXR images.
EXR is in linear RGB colorspace. You want to convert it to non-linear sRGB colorspace in Imagemagick as:
Input:
convert image.exr -set colorspace RGB -colorspace sRGB output.png