Problems on resizing images

See all posts Reply

Problems on resizing images new!
by Martina, 10 years, 1 month ago
hi,

i want to load an image and save it in diferent sizes.

the resize works fine if the target image is smaller then the original.

resizing the image bigger then the original doesn't work - it always have the size from the original loaded image.

$a_imagesize = array (
"620x320" => array ("x" => 620, "y" => 320),
"460x307" => array ("x" => 460, "y" => 307),
"300x199" => array ("x" => 300, "y" => 199),
"230x153" => array ("x" => 230, "y" => 153)
);

foreach ($a_imagesize as $key => $value) {
  $handle->file_new_name_body = $key."_imagename";        
  $handle->image_resize = true;
  $handle->image_ratio_crop = true;    
  $handle->image_x = $value['x'];            
  $handle->image_y = $value['y'];            
  $handle->image_ratio_no_zoom_in = true;
  $handle->Process($filedir); 				
}

if i load a image with original size 425x282 pixel i get folowing images:
- 230x153_imagename (SIZE: 230x153 = OK)
- 300x199_imagename (SIZE: 300x199 = OK)
- 460x307_imagename (SIZE: 425x282 = FALSE)
- 620x320_imagename (SIZE: 425x282 = FALSE)Reply
Re: Problems on resizing images new!
by colin, 10 years, 1 month ago
Can you copy here the log produced by the class while it resizes all four images?Reply
Re: Problems on resizing images new!
by Martina, 10 years, 1 month ago
hi, here is the logging part for the first image resizing.

process file to D:/xampp/htdocs/test/1\
- file size OK
- file mime OK : image/jpeg
- new file name body : 620x320_imagename
- file name safe format
- destination variables
file_dst_path : D:/xampp/htdocs/test/1\
file_dst_name_body : 620x320_imagename
file_dst_name_ext : jpg
- checking for auto_rename
- destination file details
file_dst_name : 620x320_imagename.jpg
file_dst_pathname : D:/xampp/htdocs/test/1\620x320_imagename.jpg
- 620x320_imagename.jpg doesn't exist already
- image resizing or conversion wanted
- source image is JPEG
- setting destination file type to jpg
- resizing...
check x/y sizes
doesn't calculate x/y sizes
resized image object created
image_src_x y : 425 x 282
image_dst_x y : 425 x 282
- converting...
fills in transparency with default color
- saving image...
JPEG image created
image objects destroyed
- process OKReply
Re: Problems on resizing images new!
by Martina, 10 years, 1 month ago
i think the problem ist the info:
:
doesn't calculate x/y sizes
:
but why i get this info?Reply
Re: Problems on resizing images new!
by colin, 10 years, 1 month ago
OK, I see the issue. It is because image_ratio_no_zoom_in. In fact, as per the documentation, you can use only one image_ratio_xxx at the same time.

It is a shortcoming of the class: if you use image_ratio_crop, you cannot use image_ratio_no_zoom_in or image_ratio_no_zoom_out at the same time.

It is planned to change these two settings into somehing like image_no_zoom_in and image_no_zoom_out and have them to apply to all image_ratio_xxx settings.Reply
Re: Problems on resizing images new!
by Martina, 10 years, 1 month ago
thanks,

this means that i should to comment out:
#$handle->image_ratio_no_zoom_in = true;

is this correct?Reply
Re: Problems on resizing images new!
by colin, 10 years, 1 month ago
Yes, you need to comment it out.

However, you can imitate the behaviour of image_ratio_no_zoom_in: you can read some variables before calling Process(), such as image_src_x, image_src_y and depending on the values, you do a resizing or not.Reply