Create Image Resource from Variable - NOT From File
PHP's imagecreatefromjpeg() function takes a image file name. It opens it, and loads it into an image resource. I need to load an image from somewhere on the web. URL file-access is disabled on my server, so I have to download it into memory using something like cURL.
So what I do is load the graphic into a variable, but the problem is that I can't find a way to convert that binary image data in the variable to an image resource. imagecreatefromjpeg() will only accept a file name. Am I missing something here? How do I take binary image data in a variable and load it into an image resource?
(Yes, saving it to a file and then loading it works, but why involve the file system when we don't have to?)
Greg K posted this at 22:27 — 15th July 2009.
He has: 2,145 posts
Joined: Nov 2003
imagecreatefromstring() ??
http://us2.php.net/manual/en/function.imagecreatefromstring.php
-Greg
pr0gr4mm3r posted this at 22:58 — 15th July 2009.
He has: 1,502 posts
Joined: Sep 2006
Darn it...I was thinking it was that simple. Thanks.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.