Resize & Crop issue on xampp 1.8.0 [solved]

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Resize & Crop issue on xampp 1.8.0 [solved]

Postby sXe » 07. December 2012 15:45

Hi guys, I having this annoying issue since I moved to xampp 1.8.0

This crop script doesn't work properly on Xampp 1.8.0 (thumbnails not showing up) while work fine in 1.7.7 in another machine

GD is enabled in both installations. Can be a temp folder issue?

Code: Select all
<?
header ("Content-type: image/jpeg");
$file_name=$_GET['f'];
$crop_height=$_GET['h'];
$crop_width=$_GET['w'];
$file_type= explode('.', $file_name);
$file_type = $file_type[count($file_type) -1];
$file_type=strtolower($file_type);

$original_image_size = getimagesize($file_name);
$original_width = $original_image_size[0];
$original_height = $original_image_size[1];

if($file_type=='jpg')
{
$original_image_gd = imagecreatefromjpeg($file_name);
//imagefilter($original_image_gd, IMG_FILTER_GRAYSCALE);
}

if($file_type=='gif')
{
$original_image_gd = imagecreatefromgif($file_name);
imagefilter($original_image_gd, IMG_FILTER_GRAYSCALE);
}

if($file_type=='png')
{
$original_image_gd = imagecreatefrompng($file_name);
imagefilter($original_image_gd, IMG_FILTER_GRAYSCALE);
}

$cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height);
$wm = $original_width /$crop_width;
$hm = $original_height /$crop_height;
$h_height = $crop_height/2;
$w_height = $crop_width/2;

if($original_width > $original_height )
{
$adjusted_width =$original_width / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;

imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height );
}
elseif(($original_width < $original_height ) || ($original_width == $original_height ))
{
$adjusted_height = $original_height / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;

imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height );
}
else {

imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height );
}
imagejpeg($cropped_image_gd);

?>
sXe
 
Posts: 3
Joined: 01. May 2010 21:46

Re: Resize & Crop issue on xampp 1.8.0 (while works on 1.7.7

Postby Altrea » 08. December 2012 02:01

Hi sXe,

Don't use short_open_tags <? to beginn your php script, use the full version <?php

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Resize & Crop issue on xampp 1.8.0 (while works on 1.7.7

Postby sXe » 08. December 2012 11:58

Oh man! I spent a day checking... and it was in front of my nose...

Thanks Altrea! :)
sXe
 
Posts: 3
Joined: 01. May 2010 21:46


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 141 guests