White pixel noise on JPG [6.7.7-10]

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
alibek
Posts: 3
Joined: 2019-01-30T23:03:35-07:00
Authentication code: 1152

White pixel noise on JPG [6.7.7-10]

Post by alibek » 2019-01-30T23:22:20-07:00

Hello.
I have a JPG image, to which every few minutes I output narrow vertical stripes (2-3 pixels) from another JPG image. For some reason, small white squares appear on the resulting image.
When the stripes were wider (about 50 pixels), I did not notice such a problem.
Screenshot: https://prnt.sc/mel1tf
The image is formed in this way (bash script):

Code: Select all

SRC="images.jpg"
DST="result.jpg"
let NOW=`date +"%s"`-`date --date="00:00" +"%s"`
let MW=`identify -format "%w" "$DST"`
let MH=`identify -format "%h" "$DST"`
let MX0=`calc "int(${MW}*${NOW}/86400)"`
let MX1=`calc "int(${MW}*(${NOW}+${INT})/86400)-1"`
if [ $MX1 -ge $MW ]; then let MX1=$MW-1 ; fi
let MW1=$MX1-$MX0+1
let MX2=`calc "int(${MW}*(${NOW}+2*${INT})/86400)-1"`
if [ $MX2 -ge $MW ]; then let MX2=$MW-1 ; fi
let MW2=$MX2-$MX0+1

convert "$DST" -size ${MW2}x${MH} -fill black -draw "rectangle ${MX0},0 ${MX2},${MH}" "$DST"
convert "$SRC" -crop ${MW1}x${MH}+${MX0}+0 "/tmp/crop.jpg"
composite -geometry +${MX0}+0 "$TMP/crop.jpg" "$DST" "$DST"
rm -f "/tmp/crop.jpg"
I draw a black strip on the destination image, and then I draw a strip of the dynamic image on top of it.

Version: ImageMagick 6.7.7-10 2018-05-23 Q16 http://www.imagemagick.org
OS: Linux srv-svc03 3.2.0-6-amd64 #1 SMP Debian 3.2.102-1 x86_64 GNU/Linux

User avatar
dlemstra
Posts: 1585
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: White pixel noise on JPG [6.7.7-10]

Post by dlemstra » 2019-01-30T23:56:48-07:00

And what happens with the latest version? You are using an ancient one.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

alibek
Posts: 3
Joined: 2019-01-30T23:03:35-07:00
Authentication code: 1152

Re: White pixel noise on JPG [6.7.7-10]

Post by alibek » 2019-01-31T00:10:13-07:00

On this server, I still can not update the OS and ImageMagick. But if you use PNG (instead of JPG) as the resulting image, the problem is eliminated.
As a workaround, I use PNG format images when processing, and upon completion convert PNG to JPG.

snibgo
Posts: 12398
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: White pixel noise on JPG [6.7.7-10]

Post by snibgo » 2019-01-31T03:34:29-07:00

JPG is a lossy format. This means that when you save a JPG file, the compression code changes your pixels. I strongly suggest that you never use it as an intermediate format. Always use a lossless format such as tiff or miff or png.
snibgo's IM pages: im.snibgo.com

Lars-Daniel
Posts: 37
Joined: 2015-09-20T05:55:17-07:00
Authentication code: 1151

Re: White pixel noise on JPG [6.7.7-10]

Post by Lars-Daniel » 2019-02-02T01:47:26-07:00

snibgo wrote:
2019-01-31T03:34:29-07:00
Always use a lossless format such as tiff or miff or png.
Please don't recommend PNG as an intermediate format, it cannot handle CMYK. Even when that's not important here, other users might get into trouble :-)

snibgo
Posts: 12398
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: White pixel noise on JPG [6.7.7-10]

Post by snibgo » 2019-02-02T06:40:19-07:00

Yes, that's true, PNG cannot record CMYK. Writing PNG is also rather slow, which is another reason not to use it.
snibgo's IM pages: im.snibgo.com

Post Reply