Page 1 of 1

Draw text on jpg without auto-correction

Posted: 2015-10-14T00:30:21-07:00
by hscho
To display an orange text on a grayscale JPG image I use the following command in a bash script:

Code: Select all

        convert -font Ubuntu-Mono-Regular -quality 100% -pointsize 20 -fill DarkOrange1 \
        	-draw "text 7,22 \"$position\"" \
        	-draw "text 7,472 \"BGS\"" \
        	$filename "converted/$filename"
But the converted image is much brighter and different. It seems there is some correction automatically running. How can I control this?

Original image:
img_00000575.jpg JPEG 736x480 736x480+0+0 8-bit PseudoClass 256c 23.1KB 0.000u 0:00.000

Converted image:
converted/img_00000575.jpg JPEG 736x480 736x480+0+0 8-bit DirectClass 76.9KB 0.000u 0:00.000

Re: Draw text on jpg without auto-correction

Posted: 2015-10-14T08:39:18-07:00
by snibgo
What version of IM, on what platform?

Can you provide a sample input that shows this?

I doubt that drawing text changes overall colours. Does it happen for other operations?

If the input image is greyscale, and your IM is old, then it's a RGB/sRGB problem.

Re: Draw text on jpg without auto-correction

Posted: 2015-10-15T05:42:03-07:00
by hscho
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Ubuntu

Image
Image

Re: Draw text on jpg without auto-correction

Posted: 2015-10-15T05:49:29-07:00
by hscho
Image: 00025950_0000.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Class: PseudoClass
Geometry: 736x480+0+0
Resolution: 72x72
Print size: 10.2222x6.66667
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 8-bit
Channel depth:
gray: 8-bit
Channel statistics:
Gray:
min: 0 (0)
max: 255 (1)
mean: 74.5968 (0.292536)
standard deviation: 77.8873 (0.30544)
kurtosis: 0.504794
skewness: 1.34807
Colors: 256
Histogram:
397: ( 0, 0, 0) #000000 gray(0,0,0)
...
255: (255,255,255) #FFFFFF gray(255,255,255)
Rendering intent: Undefined
Gamma: 1
Interlace: None
Background color: gray(255,255,255)
Border color: gray(223,223,223)
Matte color: gray(189,189,189)
Transparent color: gray(0,0,0)
Compose: Over
Page geometry: 736x480+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 100
Orientation: Undefined
Properties:
date:create: 2015-10-15T14:30:17+02:00
date:modify: 2015-10-15T14:15:40+02:00
jpeg:colorspace: 1
jpeg:sampling-factor: 1x1
signature: 40ebe493411ddb7e44eb22470026f6f18fd109e86e7f5efb19ed11a884137e86
Artifacts:
filename: 00025950_0000.jpg
verbose: true
Tainted: False
Filesize: 205KB
Number pixels: 353K
Pixels per second: 35.33MB
User time: 0.020u
Elapsed time: 0:01.009
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org

Re: Draw text on jpg without auto-correction

Posted: 2015-10-15T05:51:05-07:00
by hscho
Image: C_9.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 736x480+0+0
Resolution: 28.34x28.34
Print size: 25.9704x16.9372
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 1-bit
Channel statistics:
Red:
min: 22 (0.0862745)
max: 255 (1)
mean: 155.308 (0.609053)
standard deviation: 61.6487 (0.24176)
kurtosis: -1.25376
skewness: 0.429237
Green:
min: 0 (0)
max: 255 (1)
mean: 154.796 (0.607044)
standard deviation: 61.5649 (0.241431)
kurtosis: -1.22728
skewness: 0.441315
Blue:
min: 0 (0)
max: 255 (1)
mean: 154.388 (0.605444)
standard deviation: 62.0687 (0.243407)
kurtosis: -1.18578
skewness: 0.411955
Alpha:
min: 255 (1)
max: 255 (1)
mean: 255 (1)
standard deviation: 0 (0)
kurtosis: 0
skewness: 0
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 116.123 (0.455385)
standard deviation: 53.4868 (0.209752)
kurtosis: 9.70203
skewness: 0.390457
Rendering intent: Perceptual
Chromaticity:
red primary: (0.0101539,0.0052356)
green primary: (0.00475436,0.00950872)
blue primary: (0.00235147,0.000940586)
white point: (0.3127,0.329)
Interlace: None
Background color: white
Border color: srgba(223,223,223,1)
Matte color: grey74
Transparent color: none
Compose: Over
Page geometry: 736x480+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2015-10-15T14:30:17+02:00
date:modify: 2015-10-15T14:30:06+02:00
signature: 6d1cafa0fd34db6d9623eb26c66f7bc1c43e8d186b486c941b6937c2e523332f
Artifacts:
filename: C_9.bmp
verbose: true
Tainted: False
Filesize: 1.413MB
Number pixels: 353K
Pixels per second: 0B
User time: 0.010u
Elapsed time: 0:01.000
Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org

Re: Draw text on jpg without auto-correction

Posted: 2015-10-15T05:58:50-07:00
by snibgo
Yes, this is the RGB/sRGB problem.

In that version of IM, it assumed grayscale images were RGB (gamma 1), so converted them to sRGB (gamma 1/2.2) when colour was added. This was bad behaviour, and has been fixed. I suggest you upgrade.

Re: Draw text on jpg without auto-correction

Posted: 2015-10-15T07:16:40-07:00
by hscho
yes, thank you!