I created a file name image.php which contains only the following code:
<?php
function createThumbnail($picture,$thumb,$new_w,$new_h) {
$extension=substr($picture,strrpos($picture,".")+1 );
switch (strtolower($extension)) {
case "jpg":
case "jpeg":
$src_img=imagecreatefromjpeg($picture);
break;
case "png":
$src_img=imagecreatefrompng($picture);
break;
case "gif":
$src_img=imagecreatefromgif($picture);
break;
case "bmp":
$src_img=imagecreatefromwbmp($picture);
break;
}
$old_x=imagesx($src_img);
$old_y=imagesy($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}elseif ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}else{
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
switch (strtolower($extension)) {
case "jpg":
case "jpeg":
imagejpeg($dst_img,$thumb);
break;
case "png":
imagepng($dst_img,$thumb);
break;
case "gif":
imagegif($dst_img,$thumb);
break;
case "bmp":
imagewbmp($dst_img,$thumb);
break;
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
?>
This function successfully creates a thumbnail. The problem is that I
include it in another page (with include_once, just if it matters)
which creates a thumbnail, makes some db updates and then redirects to
another page. When trying to redirect with header("Location:
index.php"); it echos that header has already been sent from image.php.
The problem appears immediatly on include (I deleted the code that
calls the function to test it).
I think it is because I am using imagejpg(); function which outputs to
the browser but I don't know how to change this.
Thanks in advance
-pek
P.S. I know my coding skills are awful, so if there is anyone
suggesting to change the way I create the thumbnail please do. 4 1420
pek wrote: I created a file name image.php which contains only the following code:
<?php function createThumbnail($picture,$thumb,$new_w,$new_h) { $extension=substr($picture,strrpos($picture,".")+1 ); switch (strtolower($extension)) { case "jpg": case "jpeg": $src_img=imagecreatefromjpeg($picture); break; case "png": $src_img=imagecreatefrompng($picture); break; case "gif": $src_img=imagecreatefromgif($picture); break; case "bmp": $src_img=imagecreatefromwbmp($picture); break; }
$old_x=imagesx($src_img); $old_y=imagesy($src_img);
if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); }elseif ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; }else{ $thumb_w=$new_w; $thumb_h=$new_h; }
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
switch (strtolower($extension)) { case "jpg": case "jpeg": imagejpeg($dst_img,$thumb); break; case "png": imagepng($dst_img,$thumb); break; case "gif": imagegif($dst_img,$thumb); break; case "bmp": imagewbmp($dst_img,$thumb); break; }
imagedestroy($dst_img); imagedestroy($src_img); } ?>
This function successfully creates a thumbnail. The problem is that I include it in another page (with include_once, just if it matters) which creates a thumbnail, makes some db updates and then redirects to another page. When trying to redirect with header("Location: index.php"); it echos that header has already been sent from image.php. The problem appears immediatly on include (I deleted the code that calls the function to test it). I think it is because I am using imagejpg(); function which outputs to the browser but I don't know how to change this. Thanks in advance
-pek
P.S. I know my coding skills are awful, so if there is anyone suggesting to change the way I create the thumbnail please do.
If you actually want to display the image, you should call it as if it
were a real one:
<img src="image.php?vars" > in the html, not include it in another PHP
file.
Anyway, does the error give you a line or something? It appears because
text/whitespace is already outputted before the image is ...
Frizzle.
I don't want to output the thumbnail. I simply want to create a
thumbnail with this function. I call this function from a page where I
upload a photo, create a thumbnail out of it, save some changes to the
database, and then redirect to the homepage. If I want to see the
uploaded image I simply find it under "photos/uploadedimg.jpg" and
"photos/thumbnails/uploadedimg.jpg" (the second is created with this
function).
frizzle wrote: pek wrote: I created a file name image.php which contains only the following code:
<?php function createThumbnail($picture,$thumb,$new_w,$new_h) { $extension=substr($picture,strrpos($picture,".")+1 ); switch (strtolower($extension)) { case "jpg": case "jpeg": $src_img=imagecreatefromjpeg($picture); break; case "png": $src_img=imagecreatefrompng($picture); break; case "gif": $src_img=imagecreatefromgif($picture); break; case "bmp": $src_img=imagecreatefromwbmp($picture); break; }
$old_x=imagesx($src_img); $old_y=imagesy($src_img);
if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); }elseif ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; }else{ $thumb_w=$new_w; $thumb_h=$new_h; }
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
switch (strtolower($extension)) { case "jpg": case "jpeg": imagejpeg($dst_img,$thumb); break; case "png": imagepng($dst_img,$thumb); break; case "gif": imagegif($dst_img,$thumb); break; case "bmp": imagewbmp($dst_img,$thumb); break; }
imagedestroy($dst_img); imagedestroy($src_img); } ?>
This function successfully creates a thumbnail. The problem is that I include it in another page (with include_once, just if it matters) which creates a thumbnail, makes some db updates and then redirects to another page. When trying to redirect with header("Location: index.php"); it echos that header has already been sent from image.php. The problem appears immediatly on include (I deleted the code that calls the function to test it). I think it is because I am using imagejpg(); function which outputs to the browser but I don't know how to change this. Thanks in advance
-pek
P.S. I know my coding skills are awful, so if there is anyone suggesting to change the way I create the thumbnail please do.
If you actually want to display the image, you should call it as if it were a real one: <img src="image.php?vars" > in the html, not include it in another PHP file.
Anyway, does the error give you a line or something? It appears because text/whitespace is already outputted before the image is ...
Frizzle.
pek wrote: I created a file name image.php which contains only the following code:
<?php function createThumbnail($picture,$thumb,$new_w,$new_h) { $extension=substr($picture,strrpos($picture,".")+1 ); switch (strtolower($extension)) { case "jpg": case "jpeg": $src_img=imagecreatefromjpeg($picture); break; case "png": $src_img=imagecreatefrompng($picture); break; case "gif": $src_img=imagecreatefromgif($picture); break; case "bmp": $src_img=imagecreatefromwbmp($picture); break; }
$old_x=imagesx($src_img); $old_y=imagesy($src_img);
if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); }elseif ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; }else{ $thumb_w=$new_w; $thumb_h=$new_h; }
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
switch (strtolower($extension)) { case "jpg": case "jpeg": imagejpeg($dst_img,$thumb); break; case "png": imagepng($dst_img,$thumb); break; case "gif": imagegif($dst_img,$thumb); break; case "bmp": imagewbmp($dst_img,$thumb); break; }
imagedestroy($dst_img); imagedestroy($src_img); } ?>
This function successfully creates a thumbnail. The problem is that I include it in another page (with include_once, just if it matters) which creates a thumbnail, makes some db updates and then redirects to another page. When trying to redirect with header("Location: index.php"); it echos that header has already been sent from image.php. The problem appears immediatly on include (I deleted the code that calls the function to test it). I think it is because I am using imagejpg(); function which outputs to the browser but I don't know how to change this. Thanks in advance
-pek
P.S. I know my coding skills are awful, so if there is anyone suggesting to change the way I create the thumbnail please do.
Make sure you don't have *any* extra characters outside of the <?php and ?>
tags. That includes whitespace such as blank characters and newlines.
A common cause, for instance, is a blank or a newline character after the ?>.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Can somebody copy paste the code to a image.php file and import it and
try creating a thumbnail to see what happens..?
createThumbnail(picture as String, thumb as String, new_w as Integer,
new_h as Integer)
Parameter: picture
Path to the image that will create a thumbnail out of it
i.e. C:\test.bmp
Parameter: thumb
Path to the folder which the thumbnail will be saved
i.e. C:\thumbs\
Parameter: new_w
New width of image
Parameter: new_h
New height of image
Jerry Stuckle wrote: pek wrote: I created a file name image.php which contains only the following code:
<?php function createThumbnail($picture,$thumb,$new_w,$new_h) { $extension=substr($picture,strrpos($picture,".")+1 ); switch (strtolower($extension)) { case "jpg": case "jpeg": $src_img=imagecreatefromjpeg($picture); break; case "png": $src_img=imagecreatefrompng($picture); break; case "gif": $src_img=imagecreatefromgif($picture); break; case "bmp": $src_img=imagecreatefromwbmp($picture); break; }
$old_x=imagesx($src_img); $old_y=imagesy($src_img);
if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); }elseif ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; }else{ $thumb_w=$new_w; $thumb_h=$new_h; }
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thum b_w,$thumb_h,$old_x,$old_y);
switch (strtolower($extension)) { case "jpg": case "jpeg": imagejpeg($dst_img,$thumb); break; case "png": imagepng($dst_img,$thumb); break; case "gif": imagegif($dst_img,$thumb); break; case "bmp": imagewbmp($dst_img,$thumb); break; }
imagedestroy($dst_img); imagedestroy($src_img); } ?>
This function successfully creates a thumbnail. The problem is that I include it in another page (with include_once, just if it matters) which creates a thumbnail, makes some db updates and then redirects to another page. When trying to redirect with header("Location: index.php"); it echos that header has already been sent from image.php. The problem appears immediatly on include (I deleted the code that calls the function to test it). I think it is because I am using imagejpg(); function which outputs to the browser but I don't know how to change this. Thanks in advance
-pek
P.S. I know my coding skills are awful, so if there is anyone suggesting to change the way I create the thumbnail please do.
Make sure you don't have *any* extra characters outside of the <?php and ?> tags. That includes whitespace such as blank characters and newlines.
A common cause, for instance, is a blank or a newline character after the ?>.
-- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. js*******@attglobal.net ================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
PHP 4.3.2 with --enable-exif
I have the following class:
<?php
class ThumbGenerator extends MethodGeneratorForActionPerformer {
function ThumbGenerator() { // CONSTRUCTOR
|
by: Rennie deGraaf |
last post by:
I'm working on this page
(http://pages.cpsc.ucalgary.ca/~degraaf/test/test.html). In the central
(green-bordered) area, I want a bunch of (red-bordered) blocks each
containing a thumbnail image...
|
by: Trint Smith |
last post by:
How can I show image thumbnail??
thanks,
Trint
..Net programmer
trintsmith@hotmail.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get...
|
by: Neo Geshel |
last post by:
This works:
<form>
<asp:TextBox id="name" />
<%= name.ClientID %>
</form>
But this DOES NOT work:
<form>
|
by: K P S |
last post by:
Hi.
I'm looking for a small script that will take a .zip archive and pull
the first .jpg from the archive and convert it to a .png.
The reason for this is I want to have tuhmbnails for these...
|
by: barb |
last post by:
So that the world at large benefits from our efforts, here is one fully
documented way to use Windows Irfanview freeware to create thumbnail web
galleries (http://www.irfanview.com).
STEP 1:...
|
by: Jane |
last post by:
Hi,
I need some help (php rookie) to build a thumbnail page using php.
I'v a mysql database containing links to the original image files.
No thumbnails created so far.
It would be nice when...
|
by: empiresolutions |
last post by:
I've installed Imagemajick. phpinfo() shows it and GDlib 2.0 installed properly. I have tried multiple tests to get it to work and all have failed. Can someone please tell me what i am doing wrong....
|
by: Arno R |
last post by:
Hi all.
When I need to search for pictures, I always have too choose thumbnail-view manually.
Is it possible to open the common dialog in thumbnail-view programmatically?
Example ??
At the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |