Identify fails for remote URL

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
alex@shopnation.com
Posts: 9
Joined: 2014-05-30T17:04:38-07:00
Authentication code: 6789

Identify fails for remote URL

Post by alex@shopnation.com »

Identify fails for remote URL. curl, wget, chrome, etc.. get the image OK.
image url:

Code: Select all

http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink

Code: Select all

e7450-gd5tf72:Downloads alex$ identify -version
Version: ImageMagick 6.9.4-9 Q16 x86_64 2016-06-13 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
e7450-gd5tf72:Downloads alex$ identify "http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink"
error : Unknown IO error
identify: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504.
identify: no data returned `http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink' @ error/url.c/ReadURLImage/247.
Thanks,
Alex
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify fails for remote URL

Post by fmw42 »

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

Re: Identify fails for remote URL

Post by snibgo »

It works fine for me, IM v6.9.5-3 on Windows 8.1, at the Windows command prompt:

Code: Select all

f:\web\im>%IM%identify "http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink"

http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink=>sizer]&sink JPEG 178x234 178x234+0+0 8-bit sRGB 9.54KB 0.000u 0:00.000
The same command also works from the Cygwin bash shell.

(Personally, I wouldn't use "http:" in IM commands because comms is the slowest and least reliable part of the process, and IM isn't engineered to diagnose or recover from comms problems.)
snibgo's IM pages: im.snibgo.com
alex@shopnation.com
Posts: 9
Joined: 2014-05-30T17:04:38-07:00
Authentication code: 6789

Re: Identify fails for remote URL

Post by alex@shopnation.com »

Note sure what this has to do with the security issue.
I guessed that its something with the URL characters and got this command to work (note brackets are URL encoded):

Code: Select all

e7450-gd5tf72:keys alex$ identify 'http://images.destinationmaternity.com/dmc?set=ImageURL%5B2651696cu.jpg%5D,Imagesize%5Bthumb%5D&call=url%5Bfile:sizer%5D&sink'
http://images.destinationmaternity.com/dmc?set=ImageURL%5B2651696cu.jpg%5D,Imagesize%5Bthumb%5D&call=url%5Bfile:sizer%5D&sink=>sizer%5D&sink JPEG 178x234 178x234+0+0 8-bit sRGB 9.54KB 0.000u 0:00.000
Why would the brackets prevent the command from working?

FYI I am on OSX 10.11.6
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify fails for remote URL

Post by snibgo »

I assume that IM passes %5B etc straight through to the comms s/w, without interpretation.

Square brackets [] have a special meaning within IM, eg x.tif[3], so IM processes them specially. The code for this may have changed between your version (6.9.4-9) and mine (6.9.5-3).
snibgo's IM pages: im.snibgo.com
alex@shopnation.com
Posts: 9
Joined: 2014-05-30T17:04:38-07:00
Authentication code: 6789

Re: Identify fails for remote URL

Post by alex@shopnation.com »

curl also has issues with this url:

Code: Select all

alexs-MacBook-Pro:~ alex$ curl 'http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink' > test.jpg
curl: (3) [globbing] bad range in column 57
unless I add the -g option to disable globbing

Code: Select all

alexs-MacBook-Pro:~ alex$ curl -g 'http://images.destinationmaternity.com/dmc?set=ImageURL[2651696cu.jpg],Imagesize[thumb]&call=url[file:sizer]&sink' > test.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9537  100  9537    0     0  45990      0 --:--:-- --:--:-- --:--:-- 45850
wget seems to work OK.
alex@shopnation.com
Posts: 9
Joined: 2014-05-30T17:04:38-07:00
Authentication code: 6789

Re: Identify fails for remote URL

Post by alex@shopnation.com »

Is there any way to disable interpretation/globbing the file name/url with IM?
We are using the im4java library which calls IM on the command line and would prefer IM to download the files instead of rolling our own file management code and/or calling curl manually.
Also I just found out the IM is on github now. Is that a better place to post this issue?
alex@shopnation.com
Posts: 9
Joined: 2014-05-30T17:04:38-07:00
Authentication code: 6789

Re: Identify fails for remote URL

Post by alex@shopnation.com »

I poked around the code here: https://github.com/ImageMagick/libxml/blob/master/uri.c
and decided to workaround this issue by manually URL encoding the following characters before passing the URL to IM:

Code: Select all

{}|\^[]`
Post Reply