473,545 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

imagejpeg displays text of image name instead of image itself

Does anyone know what kind of tweaks I need to make to pertinent
configs to render an image correctly? Right now, the text of the
argument passed to imagejpeg is being shown instead of the image
itself.

Here's the code. This used to succeed until my hosting provider
changed something on his end. Now he's struggling to restore the
functionality that used to work.

<?php
// Resizer - decrease or increase an image's size proportionally
//
// Uses:
// creating uniform widths of heights for pages or tables
// Sample calls:
// <img src="resizer.ph p?imgfile=image .jpg&maxheight= 200"
border=0>
// <img src="resizer.ph p?imgfile=image .jpg&maxwidth=4 00"
border=0>
// <img src="resizer.ph p?imgfile=image .jpg&percent=0. 2"
border=0>
// Variables:
// $imgfile = name (and location, if needed) of image to resize
// $percent = in decimal format (e.g. enter 0.2 for 20%)
// $maxheight = in pixels, image's height will be set to value
passed
// $maxwidth = in pixels, image's width will be set to value
passed
//
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($i mgfile);
if (isset($_GET['maxheight'])) {
$newheight = $maxheight;
$newwidth = $width * ($maxheight / $height);
} elseif (isset($_GET['maxwidth'])) {
$newwidth = $maxwidth;
$newheight = $height * ($maxwidth / $width);
} elseif (isset($_GET['percent'])) {
$newwidth = $width * $percent;
$newheight = $height * $percent;
}
$thumb = ImageCreateTrue Color($newwidth ,$newheight);
$source = imagecreatefrom jpeg($imgfile);
imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth,
$newheight, $width, $height);
imagejpeg($thum b);
?>
Jun 27 '08 #1
9 1865
Tony Sosa wrote:
Does anyone know what kind of tweaks I need to make to pertinent
configs to render an image correctly? Right now, the text of the
argument passed to imagejpeg is being shown instead of the image
itself.

Here's the code. This used to succeed until my hosting provider
changed something on his end. Now he's struggling to restore the
functionality that used to work.

<?php
// Resizer - decrease or increase an image's size proportionally
//
// Uses:
// creating uniform widths of heights for pages or tables
// Sample calls:
// <img src="resizer.ph p?imgfile=image .jpg&maxheight= 200"
border=0>
// <img src="resizer.ph p?imgfile=image .jpg&maxwidth=4 00"
border=0>
// <img src="resizer.ph p?imgfile=image .jpg&percent=0. 2"
border=0>
// Variables:
// $imgfile = name (and location, if needed) of image to resize
// $percent = in decimal format (e.g. enter 0.2 for 20%)
// $maxheight = in pixels, image's height will be set to value
passed
// $maxwidth = in pixels, image's width will be set to value
passed
//
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($i mgfile);
if (isset($_GET['maxheight'])) {
$newheight = $maxheight;
$newwidth = $width * ($maxheight / $height);
} elseif (isset($_GET['maxwidth'])) {
$newwidth = $maxwidth;
$newheight = $height * ($maxwidth / $width);
} elseif (isset($_GET['percent'])) {
$newwidth = $width * $percent;
$newheight = $height * $percent;
}
$thumb = ImageCreateTrue Color($newwidth ,$newheight);
$source = imagecreatefrom jpeg($imgfile);
imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth,
$newheight, $width, $height);
imagejpeg($thum b);
?>
The fact it used to work indicates your code is probably OK. Your host
needs to figure out what he did to make it fail :-).
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 27 '08 #2
I know the code is okay. But the host is struggling with whatever
configuration change is mucking up the image rendering. I don't know
what Apache setting, PHP config setting, etc., would affect the
'imagejpeg" function.
Jun 27 '08 #3
Tony Sosa wrote:
I know the code is okay. But the host is struggling with whatever
configuration change is mucking up the image rendering. I don't know
what Apache setting, PHP config setting, etc., would affect the
'imagejpeg" function.
Well, are you getting any errors? Enable all errors and display them.
That might give you some ideas.

It could be a lot of things - for instance, a different version of the
gd libraries could cause it. Or a change in PHP's safe mode. Or a
couple of dozen other things.

If it's not working, you should get some error or warning message.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 27 '08 #4
Tony Sosa escribió:
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($i mgfile);
$imgfile is never defined. Do you mean $_GET['imgfile'] ?

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 27 '08 #5
On 16 Jun, 21:45, Tony Sosa <tunasu...@gmai l.comwrote:
Does anyone know what kind of tweaks I need to make to pertinent
configs to render an image correctly? *Right now, the text of the
argument passed to imagejpeg is being shown instead of the image
itself.
The argument being passed to imagejpeg is supposed to be an image
resource, not text at all.

What precisely is being shown?
Jun 27 '08 #6
On Mon, 16 Jun 2008 22:45:28 +0200, Tony Sosa <tu*******@gmai l.comwrote:
Does anyone know what kind of tweaks I need to make to pertinent
configs to render an image correctly? Right now, the text of the
argument passed to imagejpeg is being shown instead of the image
itself.

Here's the code. This used to succeed until my hosting provider
changed something on his end. Now he's struggling to restore the
functionality that used to work.

<?php
header('Content-type: image/jpeg');
list($width, $height) = getimagesize($i mgfile);
if (isset($_GET['maxheight'])) {
$newheight = $maxheight;
$newwidth = $width * ($maxheight / $height);
} elseif (isset($_GET['maxwidth'])) {
$newwidth = $maxwidth;
$newheight = $height * ($maxwidth / $width);
} elseif (isset($_GET['percent'])) {
$newwidth = $width * $percent;
$newheight = $height * $percent;
}
$thumb = ImageCreateTrue Color($newwidth ,$newheight);
$source = imagecreatefrom jpeg($imgfile);
imagecopyresize d($thumb, $source, 0, 0, 0, 0, $newwidth,
$newheight, $width, $height);
imagejpeg($thum b);
?>

1) Don't trust register_global s (the most likely culprit, where does
$imgfile come from as someone has allready pointed out).
2) If that doesn't work, enable error_reporting & display errors,
temporarily remove the header() call, and see what PHP outputs as data.

The fact you see the imagename probably just means that the browser cannot
interpret the return as an image, and will show ALT text if availble, or
the imagename if not present.
--
Rik Wasmus
....spamrun finished
Jun 27 '08 #7
It was indeed register_global s that caused my issue. $imgfile =
$_GET['imgfile'] and some other variable declarations solved my
problem. Thank you everyone for your responses.
Jun 27 '08 #8
On Jun 18, 6:38*pm, Tony Sosa <tunasu...@gmai l.comwrote:
It was indeed register_global s that caused my issue. $imgfile =
$_GET['imgfile'] and some other variable declarations solved my
problem. *Thank you everyone for your responses.
So you are still using register_global s. huh!
U should not not use that. People using for thier lazines and others
reasons are telling PHP is unsafe.
Jun 27 '08 #9
Satya wrote:
On Jun 18, 6:38 pm, Tony Sosa <tunasu...@gmai l.comwrote:
>It was indeed register_global s that caused my issue. $imgfile =
$_GET['imgfile'] and some other variable declarations solved my
problem. Thank you everyone for your responses.

So you are still using register_global s. huh!
U should not not use that. People using for thier lazines and others
reasons are telling PHP is unsafe.
It's probably nothing about being lazy. register_global s used to be the
standard for PHP, and there are still a lot of scripts out there which
haven't been corrected. So there are still hosts who have it enabled so
as to not break their customer's code.

He just finally got caught when the host disabled register_global s.
Probably didn't even know there was a problem until then.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
2694
by: Yang Li Ke | last post by:
Hi guys, Im trying to use this code that I found on php.net to create a thumbnail from an image but it simply displays a black square. Anyone can tell me what am I doing wrong? <? function ImageCopyResampleBicubic(&$dst, &$src, $dstx, $dsty, $srcx, $srcy, $w, $h, $zoomX, $zoomY = '') { if (!$zoomY) $zoomY = $zoomX;
4
2292
by: Steven Stern | last post by:
I'm sketching out an application that would automagically do a photo gallery. As part of this, I want to examine each graphic in the a given directory, look for an embedded thumbnail and, if present, output it instead of the image. Version 2... If there is no embedded thumbnail, create one and save it in the directory. I have an image...
3
3225
by: Shawn Wilson | last post by:
Hi, I've created a PHP file called filename.jpg. It outputs a JPG. I've set up a .htaccess file to force the filetype to PHP. The file is displayed in a page on a browser. I cannot get the damn thing to save as my suggested filename or even as anything but a BMP in IE6. I've tried a bunch of different combinations of the content-type...
1
2760
by: Phil Powell | last post by:
I am using the imagejpeg() and the imagegif() (also imagepng(), etc.) commands that will write an image Object back into an existing image in a directory. Everything works fine, except that when I compare image filesizes between the original and the one created via imagejpeg(), the size of the latter is 50% of that of the former. ...
1
2892
by: André Gasser | last post by:
hello newsgroup, I just discovered a weird effect in my php code. here is the flow of my code: 1. upload jepg file to server 2. create new (empty) jpeg file using imagecreatefromjpeg() function 3. use imagecopyresampled to resize src image and store in newly created image from step 2.
3
3496
by: Bob Bedford | last post by:
I'm trying to add an imagejpeg result as an attachment of an email. For creating the email I'm using phpmailer class (http://phpmailer.sourceforge.net/) Now I do create an image from a jpeg file for adding some text on it and then send it to somebody: here is the code: $image = "/include/images/model.jpg"; $src =...
21
21242
by: cman | last post by:
does anyone know why i can't generate images with: header("Content-type:image/jpeg"); imagejpeg($img_number); i've tried different examples but i always get a text output as if the header doesn't make a difference at all. <?php //random_number.php $img_number = imagecreate(100,50);
6
6793
Markus
by: Markus | last post by:
I'm adding to my script a section that allows a thumbnail to be created and saved. I get this error: Warning: imagejpeg() : Unable to open '../uploads/thumb/' for writing: Is a directory in /home/.gobbles/mahcuz/mahcuz.com/upload/uploaded.php on line 129 And this is some of the code from the page: /* New code for thumbnails. Will on work...
1
4185
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? ...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5359
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.