...

View Full Version : How Can I Set The Images Size Automatically?



Byronwells
01-16-2010, 05:20 AM
Alright Guys

I am wondering if I can automatically set the size on image that I am uploading please?

Let me try and explain..

I am using a membership script on my website.. Under the admin settings, add product page, it allows me to add an image to be displayed.. This is done via a text box...

Then the image is display on this page with the rest of the product details.. http://www.digitalresellersvault.com/marketplace.php?cat=t&category=Master_Resale_Rights

As you can tell I have an image, but the image is way much bigger.. I am wondering if there is anyway that I can write some code that tells image to be a certain size in a particular section? It doesnt matter on the size of the image that you have uploaded to the server..

Hope you understand :)

Len Whistler
01-16-2010, 05:56 AM
PHP can do all sorts of image manipulation.


http://php.net/manual/en/book.image.php




--------------------------------

Byronwells
01-16-2010, 08:08 AM
PHP can do all sorts of image manipulation.


http://php.net/manual/en/book.image.php




--------------------------------

Alright Len

Which one am I suppose to be looking at? There is one for copy an image then resize it.. Is that the one? I cant see one that say resize image

Len Whistler
01-16-2010, 07:05 PM
I recommend you go through the links on that page and scroll down for code examples. This one will display the image at half size:



<?php
// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Content type
header('Content-type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb);
?>



When you find something that's close to what you want you then modify it for your needs.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum