Page 1 of 1

Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-04T02:26:27-07:00
by kvz
Hi,

A customer of ours is trying to convert this jpg: https://www.dropbox.com/s/rd4p6x1f5sx93jd/orig.jpg?dl=1 through our service which relies on imagemagick. When the conversion is done though, the file displays properly on all devices except those running OSX (at least Yosemite) and iOS (at least 8 ).

I wrote a script that can be executed or copy-pasted to reproduce: https://gist.github.com/kvz/a9e2cabd617636db0055:

Code: Select all

#!/usr/bin/env bash
# Transloadit API2. Copyright (c) 2015, Transloadit Ltd.
#
# This file
#  - Reproduces the issue where resizing a certain jpg breaks
#    the image on OSX & iOS, wheras the original dispays fine.
#
# Reported first by Richard Taylor in http://support.transloadit.com/discussions/questions/96479-image-conversion-problem
#
# Typically called as `./debug.sh [target.jpg]`
#
# Authors:
#  - Kevin van Zonneveld <kevin@transloadit.com>

set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace

# Set magic variables for current FILE & DIR
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename ${__file} .sh)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"

converVersion="$(convert -version |awk '{print $3}' |head -n1)"
target="${1:-$converVersion}"
ext="jpg"

inFile="${__dir}/orig.${ext}"
outFile="${__dir}/${target}.${ext}"


if [ ! -f "${inFile}" ]; then
  wget "https://www.dropbox.com/s/rd4p6x1f5sx93jd/orig.jpg?dl=1" -O "${inFile}"
fi

rm -f "${outFile}"
convert \
  "${inFile}" \
"${outFile}"

echo ""
echo "${inFile}"
echo exiftool: $(exiftool "${inFile}" |egrep -i '(width|height)' || true)
echo      sips: $(sips -g pixelWidth -g pixelHeight "${inFile}" |egrep -i '(width|height)' || true)
echo ""

echo "${outFile}"
echo exiftool: $(exiftool "${outFile}" |egrep -i '(width|height)' || true)
echo      sips: $(sips -g pixelWidth -g pixelHeight "${outFile}" |egrep -i '(width|height)' || true)
echo ""
As you can see I already stripped all resize arguments to boil it down to just the convert.

After executing, it shows that the original file (orig.jpg) has dimensions according to exiftool & OSX's sips:

Code: Select all

/Users/kvz/code/api2/api2/test/regression/orig.jpg
exiftool: Exif Image Width : 1024 Exif Image Height : 768 Image Width : 1024 Image Height : 768
sips: pixelWidth: 1024 pixelHeight: 768

/Users/kvz/code/api2/api2/test/regression/6.9.1-4.jpg
exiftool: Exif Image Width : 1024 Exif Image Height : 768 Image Width : 1024 Image Height : 768
sips: pixelWidth: <nil> pixelHeight: <nil>
Yet the converted file (6.9.1-4.jpg) also has dimensions according to exiftool, but OSX's sips fails to determine its dimension. When opening in Preview on OSX or Chrome/Safari on iOS, the image does not display at all.

I tried these imagemagick versions, executed from both Ubuntu Precise and OSX Yosemite:

- 6.5.1-0
- 6.8.9-7
- 6.9.1-4

All producing the same broken image. I'd love some help here : )

Kind regards,
Kevin

Re: Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-04T03:14:30-07:00
by dlemstra
I did not look at the image (on a mobile for now) but is that image a cmyck image? Are you doing any cmyk to rgb conversion?

Re: Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-04T06:39:24-07:00
by kvz
Not doing any colorspace conversion no, the command used is:

Code: Select all

convert orig.jpg new.jpg
As for the colorspace itself, sRGB is indicated:

Code: Select all

$ identify orig.jpg
orig.jpg JPEG 1024x768 1024x768+0+0 8-bit sRGB 501KB 0.000u 0:00.000

Re: Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-04T09:24:48-07:00
by fmw42
I am using IM 6.9.1.4 Q16 and my INTEL Mac Mini with Mac OSX Snow Leopard. I did your conversion as above

convert orig.jpg new.jpg

and the file displays fine in my PREVIEW app and in my Safari.

Re: Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-04T23:34:41-07:00
by kvz
So a Yosemite/iOS8 issue maybe? It was reported by a customer and I could reproduce - leading me to think it's not my machines or clumsiness in this case ; )

Re: Converting this jpg ruins it for OSX & iOS (copy-pastable steps to reproduce included)

Posted: 2015-06-05T11:04:35-07:00
by kvz
I just got word from my customer that iOS 7 and earlier can display the converted image correctly. So it seems only Apple's latests are affected