Re: PHP + Upload + picture script



<jason.tadeo@xxxxxxxxx> wrote in message
news:1162246760.533931.252710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I was wondering if anyone does any uploading picture scripts or how to
do it where i could upload a picture and use php to change the picture
size to what i want it to be. Anyone know where i could learn how to do
this or have any script examples? i would really appreciate it alot.

thanks for you time

jason


I developed a little script that I used only for jpegs so far. I haven't
tested it with other image types. Here it is:

function thumbnail($img, $w_d, $h_d) {
// $img is the image
// $w_d is the desired width in pixels
// $h_d is the desired height in pixels
//
// function to get the width and height to display q thumbnail
// Pass in the image location, the deisred width and the desired height
// Ouput is an array of height and width to display that can be
// exploded with the list commant
list($w, $h, $type, $attr) = getimagesize($img);
$calc_width = $h_d * $w / $h;
$calc_height = $w_d * $h / $w;
if ($calc_width <= $w_d) {
$disp_width = $calc_width;
$disp_height = $h_d;
} else {
$disp_width = $w_d;
$disp_height = $calc_height;
}
return array($disp_width, $disp_height);
}


I call it with:

list($disp_width, $disp_height) = thumbnail($the_picture_location, 500,
500);

and in the html area I have:

<img src="the-picture-location" width="<?php echo $disp_height;?>"
height="<?php echo $disp_height;?>"
border="0" alt="something here" align="bottom" />

Hope that helps.

Shelly




.



Relevant Pages

  • Re: Text overlay on image then Save to JPEG with reasonable DPI for Online printshop
    ... > Let's suppose I have an image of 1500 X 1500 pixels of which I ... picture at the top right of the card, or whether it is actually the card ... memory (an invisible VB picture box or a memory bitmap or DIBSection or ... What you "display to the user" while he is ...
    (comp.lang.basic.visual.misc)
  • Re: Will F1 be on BBC HD?
    ... quality ADC to get good picture. ... of pixels for the source signal, on an HD screen there are lots more. ... The early cheap HD screens were poor at doing ... > inevitable mapping errors that you get even when using an SD display ...
    (rec.autos.sport.f1)
  • Re: Whats the deal with letterboxing Blu-ray movies?
    ... replaced it with a 50" 1080P display. ... I'm also only about 6.5 feet from my ... are bothering you from seeing a larger picture, ... 6.5 feet from a 50" 1080 panel gives a risk that the pixels ...
    (alt.tv.tech.hdtv)
  • Re: [SLE] KDE desktop refresh from script
    ... And I will set this script to be run from cron. ... >> so the new picture to be displayed. ... > this is a standar funcionality of the kde. ... > you can select a number of images to display as background and set the time ...
    (SuSE)
  • Re: PHP + AJAX + Photo Editing
    ... See the heading of the script itself, ... From php ... between the two images is greatest for the pixels near sharp edges. ... Therefore the sharp picture has to go through the same loop ...
    (comp.lang.php)