Convert url of php script into an image

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

Convert url of php script into an image

Post by marktorregrossa »

Is there a way to take a url that is php and turn that output on the webpage to an image? I'm doing this same thing using convert then the url. But that url pulls up a gif image that I can alter. I'm assuming the problem is that the webpage from the php url isn't an image. here's the url:
http://forecast.weather.gov/wtf/meteogr ... 6&psnwhr=6

The display on the webpage is actually a .png image, and I can even end the url with .png like this:
http://forecast.weather.gov/wtf/meteogr ... nwhr=6.png

Thanks for any guidance.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Convert url of php script into an image

Post by anthony »

IM should see the "http:" prefix which will override the ".php" suffix.

That means it will read and try to convert the HTTP: url directly, that is download and convert the content of the page.

If the page returned is html, then it will likely use the tool "html2ps" to do the conversion (if installed) then use "ghostscript" to convert the resulting postscript to an image. Turning on verbose should let you see what happens (I think).

If the contect is PNG however it will see the 'magick' of the PNG file and convert that. You should have no problems.

Note you will need to quote the filename, unless you have IM read the filename from a list of files. EG: "@image_list.txt"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

Re: Convert url of php script into an image

Post by marktorregrossa »

thanks much sir! I was just missing quoting the image. Sure helps to have a second set of eyes.
marktorregrossa
Posts: 6
Joined: 2011-12-28T20:23:59-07:00
Authentication code: 8675308

Re: Convert url of php script into an image

Post by marktorregrossa »

Anthony,
Now I can't get this url to work. It should be the same as the link above, but maybe it's not a url type image magick likes?

Code: Select all

#!/bin/bash
/usr/bin/convert "http://water.weather.gov/precip/index.php?yday=1328616000&yday_analysis=0&layer[]=0&layer[]=1&layer[]=4&timetype=RECENT&loctype=STATE&units=engl&timeframe=current&product=observed&loc=conus.gif" -crop 627x409+450+350 +repage farmerweather/images/observedprecip/precip_last_24hrs.gif
Can you let me know if you think this type of url wont work.
thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert url of php script into an image

Post by fmw42 »

/usr/bin/convert "http://water.weather.gov/precip/index.p ... =conus.gif" -crop 627x409+450+350 +repage farmerweather/images/observedprecip/precip_last_24hrs.gif
I believe the boxes mean that there is some character that is not recognized. Check your link an see what was there. You may need to find the correct html escaped characters. Or you have brackets that may not be properly resolved or missing some character or numeral inside them.
Post Reply