Bigger thumbnails

Kwb

I did the same tweak for PNG images, it works fine, however since the thumbnails are converted to JPG, a background color is set automatically, that is black.
Can I change the background coloro to white?

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?

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;
}

...
}

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

if (!($fileext == "png")) {
                                make_thumb($new_file, $thumb_destination, $resize);


to
if (!($fileext == "png")) {
                                make_bakery_thumb($new_file, $thumb_destination, $resize);


the original function works with $size = $resize.
$resize comes from here -> $SIZES['182'] = '182x182px';
(modify_page_settings.php ) and the 182 is saved in the database mod_bakery_page_settings. than change the code in the "new" function like the postet code from your last posting

Kwb

I tried to modify the following in resize_img.php but it still acts on the maximum lenght of the image.

// 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;
}
...


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

QuoteWell if the image is 600x1000 and I set 182x182 thumbnails, I want it resized 182x303 .
Should I change code in resize_img.php ?

the 182 in this line (modify_page_settings.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

else if ($orig_h > $new_max_h) {
                        $new_h = $new_max_h;
                        $new_w = intval($orig_w * ($new_h / $orig_h));
                        $resize = TRUE;}





Kwb

Quote from: jacobi22 on September 26, 2012, 01:59:32 PM
read my Example:
Quoteif 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

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
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

read my Example:
Quoteif 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

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

Kwb

#4
Is it possible to bind the resizing only to the width?
I did some manipulation to the code without success..
First of all I modified modify_page_settings.php and added my custom size (182 px).

$SIZES['40']  = '40x40px';
$SIZES['50']  = '50x50px';
$SIZES['60']  = '60x60px';
$SIZES['75']  = '75x75px';
$SIZES['100'] = '100x100px';
$SIZES['125'] = '125x125px';
$SIZES['150'] = '150x150px';
$SIZES['182'] = '182x182px';

And I set it as default in the page settings panel.

Then I tried to modify the file pngthumb.php:

function make_thumb_png($source, $destination, $size) {
// Check if GD is installed
if (extension_loaded('gd') AND function_exists('imageCreateFromPng')) {
// First figure out the size of the thumbnail
list($original_x, $original_y) = getimagesize($source);

$thumb_w = $size;
$thumb_h = $original_y*($size/$original_x);

/*if ($original_x > $original_y) {
$thumb_w = $size;
$thumb_h = $original_y*($size/$original_x);
}
if ($original_x < $original_y) {
$thumb_w = $original_x*($size/$original_y);
$thumb_h = $size;
}
if ($original_x == $original_y) {
$thumb_w = $size;
$thumb_h = $size;
}*/
// Now make the thumbnail
...


I thought that in this way the resizing for thumbnails was just on width, but bakery keeps resizing on the biggest lenght ( either width or height )

Kwb


jacobi22

#2
modify_page_settings.php at line 171 ff.

$SIZES['40']  = '40x40px';
$SIZES['50']  = '50x50px';
$SIZES['60']  = '60x60px';
$SIZES['75']  = '75x75px';
$SIZES['100'] = '100x100px';
$SIZES['125'] = '125x125px';
$SIZES['150'] = '150x150px';


build your own $SIZES behind the last line here, maybe
$SIZES['250'] = '250x250px';

for the Standard-Sizes, its works without coding, the 150 px are the max-width or max-height, not both.

for example: 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


[gelöscht durch Administrator]

Kwb

Hi there!
I'm trying to customize bakery for my website. Right now, I need to disable resizing of thumbnails or allow a bigger thumbnail size and size should be only on width.
Is that possible?