-
XRave
PHP Thumbnail Generator not working, can JS do it?
Hey guys, it's been long (bet you don't remember me already).
I've made a art website gallery for my school's Art Dept. But I ran into a tiny snag. while using a php thumbnail generator - which is working perfectly fine on my own web host - the school server does not seem to like using PHP to generate images. Browser-testing returned exactly what i put into the address bar, causing a Error XXXX Unsupported file format error in Flash
here's the code
PHP Code:
<?php header ("Content-type: image/jpeg"); /* JPEG / PNG Image Resizer Parameters (passed via URL):
img = path / url of jpeg or png image file
percent = if this is defined, image is resized by it's value in percent (i.e. 50 to divide by 50 percent)
w = image width
h = image height
constrain = if this is parameter is passed and w and h are set to a size value then the size of the resulting image is constrained by whichever dimension is smaller
Requires the PHP GD Extension
Outputs the resulting image in JPEG Format
By: Michael John G. Lopez - www.sydel.net Filename : imgsize.php */
$img = $_GET['img']; $percent = $_GET['percent']; $constrain = $_GET['constrain']; $w = $_GET['w']; $h = $_GET['h'];
// get image size of img $x = @getimagesize($img); // image width $sw = $x[0]; // image height $sh = $x[1];
if ($percent > 0) { // calculate resized height and width if percent is defined $percent = $percent * 0.01; $w = $sw * $percent; $h = $sh * $percent; } else { if (isset ($w) AND !isset ($h)) { // autocompute height if only width is set $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } elseif (isset ($h) AND !isset ($w)) { // autocompute width if only height is set $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } elseif (isset ($h) AND isset ($w) AND isset ($constrain)) { // get the smaller resulting image dimension if both height // and width are set and $constrain is also set $hx = (100 / ($sw / $w)) * .01; $hx = @round ($sh * $hx);
$wx = (100 / ($sh / $h)) * .01; $wx = @round ($sw * $wx);
if ($hx < $h) { $h = (100 / ($sw / $w)) * .01; $h = @round ($sh * $h); } else { $w = (100 / ($sh / $h)) * .01; $w = @round ($sw * $w); } } }
$im = @ImageCreateFromJPEG ($img) or // Read JPEG Image $im = @ImageCreateFromPNG ($img) or // or PNG Image $im = @ImageCreateFromGIF ($img) or // or GIF Image $im = false; // If image is not JPEG, PNG, or GIF
if (!$im) { // We get errors from PHP's ImageCreate functions... // So let's echo back the contents of the actual image. readfile ($img); } else { // Create the resized image destination $thumb = @ImageCreateTrueColor ($w, $h); // Copy from image source, resize it, and paste to image destination @ImageCopyResampled ($thumb, $im, 0, 0, 0, 0, $w, $h, $sw, $sh); // Output resized image @ImageJPEG ($thumb); } ?>
[edit] okay - so the GD Extension is needed...
So now, I'm stuck. I cannot possibly host the php file somewhere else, or ask the school to install the GD extension. Does anyone have any suggestions? (can I somehow attach the GD Library to the directory without access to the console?) Is there a way to use JavaScript or some other code (no Ruby, ASP or anything unrealistic for a simple school server please) or anything that to do the same thing?
Thanks
Xrave
Last edited by tongxn; 06-22-2010 at 04:51 PM.
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
Hi,
if there is no GD, maybe there is ImageMagick instead, or maybe you can exec a
standalone Imagemagick
create a php file with only
<?phpinfo();?>
and have a look.
Musicman
-
XRave
mkay ^^ thanks. I don't have access to school FTP currently >.> but I'll see where to go from there.
When you actually know what "OMG I have so much homework!" means, you won't want to be me.
Xrave
-
I think you should also look to system requirements of this software.
I.g php form generator need the following script requirements:
# Unix/Linux/Windows Server OS
# Apache/IIS Server
# PHP 4.1.x - 5.x
# MySQL 4.1.xx or later
# Zend Optimizer v3.0.0 or higher
Last edited by Frakas; 07-16-2010 at 10:59 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|