WebsiteBaker Support (2.8.x) > Bakery Shop
Bigger thumbnails
Kwb:
--- Quote from: jacobi22 on September 26, 2012, 01:59:32 PM ---read my Example:
--- Quote ---if you have a pic 1000 x 600 px and you change the THUMBNAIL-SIZE in Page-Settings to 150 x 150
your thumb is 150 x 90
--- End quote ---
if you need thumbs with 182 x 182, your big picture need the same lenght for width AND height
P.S. the file pngthumb.php builds only thumbnails from a big picture in png-Format.
the real works make the file resize_img.php. you dont need to change something in this file if the big picture are with the same lenght for width and hight
--- End quote ---
Well if the image is 600x1000 and I set 182x182 thumbnails, I want it resized 182x303 .
Should I change code in resize_img.php ?
jacobi22:
--- Quote ---Well if the image is 600x1000 and I set 182x182 thumbnails, I want it resized 182x303 .
Should I change code in resize_img.php ?
--- End quote ---
the 182 in this line (modify_page_setting s.php // Line 171ff.) is the maximum for thumbnail width or height. if you need a fix width from 182px and a proportional height to this width, you must change the code in the resize_img.php
i think, you dont need this part here (not testet) in both functions function resizePNG & function resizeJPG
--- Code: ---else if ($orig_h > $new_max_h) {
$new_h = $new_max_h;
$new_w = intval($orig_w * ($new_h / $orig_h));
$resize = TRUE;}
--- End code ---
Kwb:
I tried to modify the following in resize_img.php but it still acts on the maximum lenght of the image.
--- Code: ---// Resize PNG image
function resizePNG($source, $destination, $new_max_w, $new_max_h) {
// Check if GD is installed
if (extension_loaded('gd') AND function_exists('imagecreatefrompng')) {
// First figure out the size of the image
list($orig_w, $orig_h) = getimagesize($source);
//Fix for fixed size width
if ($orig_w > $new_max_w) {
$new_w = $new_max_w;
$new_h = intval($orig_h * ($new_w / $orig_w));
}
else {
// Image to small to be downsized
echo "<div align='center'><p style='color: red;'>Image to small to be downsized!</p></div>";
return false;
}
...
}
// Resize JPEG image
function resizeJPEG($source, $new_max_w, $new_max_h, $quality = 75) {
if ($img = imagecreatefromjpeg($source)) {
$orig_w = imagesx($img);
$orig_h = imagesy($img);
$resize = FALSE;
$handle;
//Fix for fixed size width
if($orig_w > $new_max_w){
$new_w = $new_max_w;
$new_h = intval($orig_h * ($new_w / $orig_w));
$resize = TRUE;
}
else {
// Image cant be downsized
echo "<div align='center'><p style='color: red;'>Image to small to be downsized!</p></div>";
return false;
}
...
--- End code ---
The images I will add to the bakery section will always be longer than larger, however due to how I constructed the css template, I need the images to have a fixed width.
I really don't get what's wrong...
jacobi22:
i try it by myself and now, i understand... :x
bakery use the WebsiteBaker-function make_thumbs() to build the thumbnails, the file resize_img.php works only, if you like to change / resize a saved pic (not a new)
i think, the best way is: copy the function make_thumb() from framework/function.php into the save_item.php in the bakery-folder or into the resize_img.php, rename the function - like make_bakery_thumbs()
and change the function and this line here
--- Code: ---if (!($fileext == "png")) {
make_thumb($new_file, $thumb_destination, $resize);
--- End code ---
to
--- Code: ---if (!($fileext == "png")) {
make_bakery_thumb($new_file, $thumb_destination, $resize);
--- End code ---
the original function works with $size = $resize.
$resize comes from here -> $SIZES['182'] = '182x182px';
(modify_page_setting s.php ) and the 182 is saved in the database mod_bakery_page_set tings. than change the code in the "new" function like the postet code from your last posting
Kwb:
Fine, more or less it's working.
The only issue I can see now is that if I load an image that is smaller than the thumbnail size set, the relative error saying 'The image cannot be resized' appears but the image is not loaded on the server.
If I try to click on the image a 404 error appears.
I think it's due to the return false; i put.
Is that right?
--- Code: ---function make_bakery_thumb($source, $destination, $size)
{
// Check if GD is installed
if(extension_loaded('gd') && function_exists('imageCreateFromJpeg'))
{
// First figure out the size of the thumbnail
list($original_x, $original_y) = getimagesize($source);
if( $original_x >= $size ) {
$thumb_w = $size;
$thumb_h = $original_y*($size/$original_x);
}
else if ($original_x == $original_y) {
$thumb_w = $size;
$thumb_h = $size;
}
else {
echo "<div align='center'><p style='color: red;'>Image too small to be downsized!</p></div>";
return false;
}
...
}
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version