PHP Classes

multiple images

Recommend this page to a friend!

      HolyImage  >  All threads  >  multiple images  >  (Un) Subscribe thread alerts  
Subject:multiple images
Summary:output a number of different images at one time
Messages:3
Author:GarryDonovan
Date:2009-01-27 10:08:07
Update:2009-01-27 11:54:20
 

  1. multiple images   Reply   Report abuse  
Picture of GarryDonovan GarryDonovan - 2009-01-27 10:08:07
Hi
I tested the image conversion script and it worked fine.
I tried to output 4 different images at the one time and it gave me 4 images of the first image it processed.
Is there a way to do multiple images.

<?php

include_once("image.php");

/*
* The constructor of the class get the type of the file being suplied to it and use the correct function of GD library
* to create the image in the memory.
* In this example we will be loading a JPEG image, for a PNG or GIF image the command is the same, just suply the filename
* and the class take care of the correct command for the extension.
* If the extension of the file is unsupported, the class will throw a ErrorException!
*/
$image = new Image("new1.jpg");
$image = new Image("new2.jpg");
$image = new Image("new3.jpg");
$image = new Image("new4.jpg");

/*
* So lets say you want to resize the image and maintain the aspect of the image, in case you want an especific width and height
* the class will crop the equaly the sides of the image (verticaly or horizontaly, depends on the final aspect you want based on the
* width and height you want) and resample the image to the desired width and height!
* In case you only want a desired width, you can use the resampleProportionWidth or for the height resampleProportionHeight method.
* In case you only want to resample, without caring the aspect of the final image just use resample method!
*/
$image->resampleCropProportion(200, 150);

/*
* For outputing the image, we will be converting the image to PNG and outputing to a file with a quality (in case of PNG
* the quality parameter is used as compression) of 9, and will be outputing to a file but we can just output it on the
* screen just by supling a NULL filename parameter!
* The class also defines some constants for the types of the images that can be suplied in the first parameter, but you
* can also suply the mimetype as a string!
*/
$image->output(PNG, "new1.png", 9);
$image->output(PNG, "new2.png", 9);
$image->output(PNG, "new3.png", 9);
$image->output(PNG, "new4.png", 9);

/**
* Let's just show as HTML the new image to see what happened!
*/
echo "<img src=\"new1.png\" />";
echo "<img src=\"new2.png\" />";
echo "<img src=\"new3.png\" />";
echo "<img src=\"new4.png\" />";
?>

  2. Re: multiple images   Reply   Report abuse  
Picture of GarryDonovan GarryDonovan - 2009-01-27 10:15:19 - In reply to message 1 from GarryDonovan
Disreguard that message, I wasn't thinking, all fixxed.

  3. Re: multiple images   Reply   Report abuse  
Picture of Marcos Taranta Marcos Taranta - 2009-01-27 11:54:20 - In reply to message 2 from GarryDonovan
No problem dude, as a programmer everyone knows that this kind of thing happens all the time, if you didn't figured your error out, you were creating instances of the object in the same variable name, so instead of 4 differents objects you were creating just one object.
Also thank you very much for the support, and any question please feel free to ask me!