LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2007, 09:08 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
PHP: how can I return an image - not the html img src tag, but the image data


You can make php create an image & then return it as an image to the browser. I want to do that, but instead of creating an image with rectangles, text, and such, I want to grab an image from the internet, then return it as if it were made by php - i.e., return image data - a jpeg, for instance. Is this possible? Am I explaining myself clearly enough?
 
Old 05-17-2007, 09:24 PM   #2
shambler
Member
 
Registered: Sep 2006
Location: Canada
Distribution: openSUSE 11.3, Xubuntu 10.10, Ubuntu 11.04
Posts: 53

Rep: Reputation: 23
Sounds like hotlinking the hard way. Get permission, then just read it as a file.
 
Old 05-18-2007, 02:07 AM   #3
senyahnoj
Member
 
Registered: Jul 2004
Location: Gloucestershire, UK
Distribution: Ubuntu, Debian & Gentoo
Posts: 74

Rep: Reputation: 16
PHP Code:
<?
$im 
file_get_contents('http://www.linux.org/images/logo/linuxorg.gif');
header('content-type: image/gif');
echo 
$im;
?>
 
Old 05-18-2007, 02:28 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by shambler
Sounds like hotlinking the hard way. Get permission, then just read it as a file.
Well, I'm "hotlinking" from myself, if you even want to call it hotlinking - which would be a stretch. Thanks for the assumption and complete lack of help.

Quote:
Originally Posted by senyahnoj
PHP Code:
<?
$im 
file_get_contents('http://www.linux.org/images/logo/linuxorg.gif');
header('content-type: image/gif');
echo 
$im;
?>
That worked great. I was trying imagecreatefromgif($file) where $file was a stream that comes from fopen on a URL without much luck.

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php image blob managing cannot get image from html ilpadrino Programming 6 04-15-2007 09:05 AM
Name of an El Torito Boot Image - ISO Img & mkisofs BlueSpirit Linux - Software 2 04-05-2007 01:59 PM
how to mount .img cd image created with k3b sunpascal Linux - Software 3 01-31-2006 08:36 PM
Php to return a binary not html logicdisaster Programming 3 10-07-2004 01:25 PM
mozilla, html, <img src= ... alt= ... > itsjustme Linux - Software 19 08-08-2003 05:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration