ImageMagick: convert [label:] - imagemagick-convert

There is a command:
/Path_to/convert \
-background LightBlue1 \
-border 10 \
-bordercolor red \
-font Helvetica-Bold-Oblique \
-fill blue \
-pointsize 72 \
label:\
"\n`date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S"`\n\n\
--Text!--" \
"/Users/user/Pictures/Test_Image.png"
The command works correctly (the image file is being created
identify /Users/user/Pictures/Test_Image.png
/Users/user/Pictures/Test_Image.png PNG 647x386 647x386+0+0 16-bit sRGB 45148B 0.000u 0:00.000
), but I need to "--Text! -" it was printed with other font, color and size, rather than the rest of the text.
My attempts to solve this failed.
How to do it?
Thankful in advance for the help!
P.S.
convert --version
Version: ImageMagick 6.9.9-40 Q16 x86_64 2018-07-28 http://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps raw tiff webp x xml zlib
uname -a
Darwin Air.local 13.4.0 Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64 x86_64

Related

How to set a particular colorspace for the output in imagemagick

How to control the colorspace in the output file using convert. I tried
convert __targets/test_pattern_raw.png -set colorspace RGB -depth 16 -colorspace RGB PNG64:__targets/test_pattern.png
First I set colorspace to RGB, because the input file has falsely been tagged as sRGB. Now I want to save the image in linear space as well. However, the command above gives a non-linear image:
identify __targets/test_pattern.png
__targets/test_pattern.png PNG 1600x1000 1600x1000+0+0 16-bit sRGB 78794B 0.000u 0:00.000
When saving in EXR format, it becomes linear, because EXR does not support anything else, but I need it to work for png, and also for rgba (which is a dump without any headers).
It should work by simply using -colorspace RGB in Imagemagick.
Input:
Filename: lena.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 256x256+0+0
Units: Undefined
Colorspace: sRGB
convert lena.png -colorspace RGB x.png
Filename: x.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 256x256+0+0
Units: Undefined
Colorspace: RGB
The problem was a bug in ImageMagick. After the fix
convert -set colorspace RGB __targets/test_pattern_raw.png -depth 16 PNG64:__targets/test_pattern.png
Works as intended.

Pngs are blank when using convert

The following is giving me a blank image of the expected size:
magick convert a.png b.png -compose difference -composite out.png
However, I can produce the correct output as a jpg:
magick convert a.png b.png -compose difference -composite out.jpg
I then tried to convert this to a png and it works fine:
magick convert out.jpg out.png
Why is the first command giving me a blank image and how might I fix the problem?
Libpng version 1.6.37.
Version: ImageMagick 7.0.11-8 Q16 x86_64 2021-04-17 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib freetype gslib heic jng jp2 jpeg lcms lqr ltdl lzma openexr png ps tiff webp xml zlib
UPDATE:
Bmp is also blank:
magick convert a.png b.png -compose difference -composite out.bmp
And this also works for jpg but not png:
composite -compose difference a.png b.png out.png
And this is what I see when running verbose:
a.png PNG 500x700 500x700+0+0 8-bit sRGB 125771B 0.030u 0:00.016
b.png PNG 500x700 500x700+0+0 8-bit sRGB 90207B 0.020u 0:00.012
a.png=>b.png PNG 500x700 500x700+0+0 8-bit sRGB 90207B 0.450u 0:00.084
This is working and is giving my the required output:
composite -verbose -compose minus a.png b.png out.png

In ZSH, redirecting image file into graphic magick results in corrupt jpeg data (but not when using file path parameters)

Currently in my ZSH shell.
Doing this, gives me:
> gm convert -compress JPEG - - < input.jpg > output.jpg
gm convert: Corrupt JPEG data: 873 extraneous bytes before marker 0xd9 (/tmp/gmo1fx92).
However these 2 work without any problems:
> cat input.jpg | gm convert -compress JPEG - - > output.jpg
> gm convert -compress JPEG input.jpg output.jpg
What could be causing this difference?

Imagemagick depth convert

Having an imgage in.png. Now do the next:
$ convert in.png -strip out.tiff #convert to tiff
$ convert out.tiff -strip out.png #and back
$ cmp in.png out.png
$#no output - the images has no difference - theyre same
$ identify in.png out.png
in.png PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out.png[1] PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
now trying this via eps. So:
$ convert in.png -strip out2.eps #convert to eps
$ convert out2.eps -strip out2.png #back
and the images are different.
$ identify in.png out.png out2.png
in.png PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out.png[1] PNG 300x300 300x300+0+0 16-bit sRGB 1.65KB 0.000u 0:00.000
out2.png[2] PNG 300x300 300x300+0+0 8-bit sRGB 4c 321B 0.000u 0:00.009
As you can see, the conversion eps -> png creates 8-bit png.
Curiosity plus - the EPS is 16 bit!
$ identify out2.eps
out2.eps PS 300x300 300x300+0+0 16-bit sRGB 1.42KB 0.000u 0:00.000
Questions:
why the eps->png conversion changes the bit-depth?
how to convert from eps to png to get 16-bit png? (as from tiff).
EDIT
Tested #Rachel recommendation:
$ convert out2.eps -depth 16 out3.png
$ identify out3.png
out3.png PNG 300x300 300x300+0+0 8-bit sRGB 4c 518B 0.000u 0:00.000
8 bit again.
My ImageMagick version:
$ convert --version
Version: ImageMagick 6.8.9-1 Q16 x86_64 2014-06-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib djvu fftw fontconfig freetype gslib gvc jng jp2 jpeg lcms ltdl lzma pangocairo png ps tiff webp wmf x xml zlib
If anyone want test, here is my test image:
FINAL
So, #Mark Setchell and #Rachel Gallen's recommendation are good. #Marks command works, so the key is PNG48.
$ convert out2.eps -depth 16 PNG48:out7.png
$ identify out7.png
out7.png PNG 300x300 300x300+0+0 16-bit sRGB 1.86KB 0.000u 0:00.000
Finally 16-bit png. What I will ask it in another question, why the next:
$ mogrify -strip out7.png
$ identify out7.png
out7.png PNG 300x300 300x300+0+0 8-bit sRGB 4c 321B 0.000u 0:00.000
8 bit again. And the -strip should remove only metadata and should not change the image itself.
I think you need something along these lines to get 16-bit PNGs
convert a.png -depth 16 PNG48:b.png
i think from looking at the docs you can do
convert -depth 16 image.eps image2.png[16]
the syntax is
convert [ options … ] file [file …] file
This site says 'Use an optional index enclosed in brackets after a file name to specify a desired subimage of a multi-resolution image format like Photo CD (e.g. img0001.pcd[4]) or a range for MPEG images (e.g. video.mpg[50-75]).'
so maybe put the [16] after image2.png

Rotate PNG by ImageMagick

I want to rotate PNG file by convert command.
like this.
convert -background 'rgba(0,0,0,0.5)' -rotate 45 1.png r1.png
But result PNG file is wrong like following.
https://docs.google.com/spreadsheet/ccc?key=0AqzGWe_mT6dwdEIwa04xRldwVGtOX1VGbVJhRnZwX0E
The gray space is correct.
I don't know why black space exists.
What am I wrong?
thank you.
convert -version
Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
The image to modify comes straight after convert.
Try:
convert 1.png -background "rgba(0,0,0,0.5)" -rotate 45 r1.png
This worked for me
$ convert 1.png -distort SRT -ANGLE_IN_DEGREES -gravity center r1.png

Resources