/    Sign up×
Community /Pin to ProfileBookmark

Grab Image From Redirecting Link

I am looking for a way to pull images from an external server and save it on my server for a flash image viewer. The link to gain the avatar picture redirects to there main image here is an example. The issue im having it its not pulling the image from the redirect I have found one that will pull it but if the file extension is something other then jpg it will not pull the image at all. I am in need of a way to pull these images with gif,jpg,png,etc file extentions

redirect links to image they all go to the same place.
[url]http://www.imvu.com/catalog/web_av_pic.php/av/wishmaster/img/avatar.jpg[/url]
[url]http://www.imvu.com/catalog/web_av_pic.php?av=wishmaster[/url]

change the name wishmaster to the avatar pic you want to view example
[url]http://www.imvu.com/catalog/web_av_pic.php?av=mdrax[/url]

but the file extensions change is my issue

[code=php]<?
$img = imagecreatefromjpeg(“http://www.imvu.com/catalog/web_av_pic.php/av/wishmaster/img/avatar.jpg”);
imagejpeg($img, “/home/content/…”);
?>[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@oomagnumooFeb 16.2010 — That function "imagecreatefromjpeg" is a GDLibrary function which now comes compiled standard on PHP.

The GDLibrary has more functions that you can find @ http://php.net/manual/en/function.imagecreatefromjpeg.php such as

imagecreatefrompng

imagecreatefromwbmp

imagecreatefromgif

etc.

So pull the URL, and do a switch statement. From the extension, call the appropiate image create feature and feed this into your flash image directory (or D?.

[code=php]
switch(substr($URL, -1, 3)) {
case "jpg":
// imagecreatefromjpeg
break;
case "gif":
//imagecreatefromgif
break;
case "png":
//imagecreatefrompng
break;
default:
echo "error, unrecognized file type";

}
[/code]
Copy linkTweet thisAlerts:
@andreonauthorFeb 16.2010 — the switch command wont work being the redirect is not on my server its on the server im trying to pull from
×

Success!

Help @andreon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...