简体   繁体   中英

Weird “border” with jpegtran when rotating an image

I'm using jpegtran to rotate my images, but it seems to be doing some weird stuff. The same code/logic worked on my other server. Here is a test case I've done:

test.jpg is the original image, then I run:

jpegtran -rotate 90 test1.jpg > test2.jpg.tmp
mv test2.jpg.tmp test2.jpg
jpegtran -rotate 90 test2.jpg > test3.jpg.tmp
mv test3.jpg.tmp test3.jpg

test.jpg:

test1.jpg

test2.jpg

test2.jpg(第一次旋转)

test3.jpg:

test3.jpg(第二次旋转)

As you should be able to see, there are weird borders on it (almost like shadows on another part of the image):

在此处输入图片说明

What would cause this, and how can I get around it?

The OLD server shows:

jpegtran -v
libjpeg-turbo version 1.2.1 (build 20131209)
Copyright (C) 1991-2010 Thomas G. Lane, Guido Vollbeding
Copyright (C) 1999-2006 MIYASAKA Masaru
Copyright (C) 2009 Pierre Ossman for Cendio AB
Copyright (C) 2009-2012 D. R. Commander
Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies)

Emulating The Independent JPEG Group's libjpeg, version 6b  27-Mar-1998

...and the NEW server shows:

jpegtran -v
Independent JPEG Group's JPEGTRAN, version 9b  17-Jan-2016
Copyright (C) 2016, Thomas G. Lane, Guido Vollbeding

Typically, no sooner had I written the question out and posted it, I found the solution :)

http://www.imagemagick.org/discourse-server/viewtopic.php?t=21341#p87099

Basically, to add "-trim" to the command - so it looks like:

jpegtran -rotate 90 -trim test1.jpg > test2.jpg.tmp
mv test2.jpg.tmp test2.jpg
jpegtran -rotate 90 -trim test2.jpg > test3.jpg.tmp
mv test3.jpg.tmp test3.jpg

I've just tried this out, and it works as expected :) Thought I would post it here in case anyone else comes across this!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM