Keyword

creat thumbnail by width and height. you can input height value on K2 control center

More
14 years 1 week ago #75430 by BBC
Here is how to resize images by width and height, but images (portret and lanscape) will keep ratio/proportions.

And images in Blog layout will allways have same dimensions in px (for instance, all images will be 150 px width X 100px height.)

 

Just tested and it works perfectly.

Decide width and height in px, then new thing is background-color for part of image block that is over.

So, black color will be top-bottom or left-right, in relation to pictures, depending if you have landscape or some picture with great height. (you can use any color you want)

And chose everything below to suit your needs (tex,S,L,XL)

 

//Medium image                $handle->image_resize = true;                $handle->image_ratio = true;                $handle->image_convert = 'jpg';                $handle->image_ratio_fill = true;                $handle->image_background_color = '#000000';                $handle->jpeg_quality = $params->get('imagesQuality');                $handle->file_auto_rename = false;                $handle->file_overwrite = true;                $handle->file_new_name_body = $filename.'_M';                if (JRequest::getInt('itemImageM')) {        $imageWidth = JRequest::getInt('itemImageM');        } else {        $imageWidth = $params->get('itemImageM', '100');        }        if (JRequest::getInt('itemImageM_Height')) {        $imageHeight = JRequest::getInt('itemImageM_Height');        } else {        $imageHeight = $params->get('itemImageM_Height', '115');        }        $handle->image_x = $imageWidth;        $handle->image_y = $imageHeight;        $handle->Process($savepath);

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75431 by BBC
If it could be some way to override class.upload in K2 Admin.

www.verot.net/php_class_upload_docs.htm

 

Amazing what you can achieve with this.

But, you have only 5 shots.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75432 by juju
Thanks, but where did I put that code ?

 

So, your code could be repeated with different px value for each format (S, L, XL...) ?

 

I don't really understand why did you put a color background, your code don't crop the image so it fills the space ?

 

Thanks again ;)

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75433 by BBC
Sorry, it is

administrator/components/com_k2/models/item.php

 

Be carefull with this. You need to be sure that this tweak is not used ( XS, S,XL,M,L ) for some Category where you don´t want it this way.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75434 by BBC
You can use this code for any type of images (all 5 - XS, XL, S, M, L). Just adapt it as you wish.

If you dont use $handle->image_background_color = '#000000';  then default color is white. It is up to you to decide.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75435 by juju
Ok ;)

 

But I don't really understand.

If I have an image : 300px * 450px

 

I want to have a full thumbnail (no black stripes...) of size 200px * 100px.

 

Your script can do it ?

 

Thanks ;) 

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75436 by BBC
You can have same color as your template background. (white, or some else)

Your picture, doesn´t matter if it is landscape od portrait, will allways be centered in image block.

 

It wont lose proportions.

 

If you don´t understand. You can have same thumbs in Category blog in pixels (remember borders ?), and still don´t lose proportions and ratio for tex portrait of Barack Obama and for some panorama picture.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75437 by BBC
Height is key here. Your pictures wont lose proportions and wont decide height in px.

And you have whole picture naturally, not cropped from center or similar.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75438 by juju
So your script do that :

 



 

I'm wrong ?

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75439 by BBC
Yes, like this. This would be default, white background. There is not some portrait picture there, but principle it like this.

I chosed black because i find it more elegant sometimes.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75440 by BBC
Don´t call it my script. :)

 

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75441 by juju
Ok, if I want to crop (zoom if needed) to have a full image, how I can do ?

 

Thanks ;)

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75442 by BBC
Use that link above. All there is allowed to use in K2. If your server supports it.$handle->image_ratio_crop = true; (I guess default is center crop ?)or calculate byself$handle->image_crop = array(50,40,30,20); OR '-20 20%'...

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75443 by juju
Ok, so tomorrow I'll test that :

 

//Medium image                $handle->image_resize = true;                $handle->image_ratio_crop = true;                $handle->image_convert = 'jpg';                $handle->image_ratio_fill = true;                $handle->image_background_color = '#000000';                $handle->jpeg_quality = $params->get('imagesQuality');                $handle->file_auto_rename = false;                $handle->file_overwrite = true;                $handle->file_new_name_body = $filename.'_M';                if (JRequest::getInt('itemImageM')) {        $imageWidth = JRequest::getInt('itemImageM');        } else {        $imageWidth = $params->get('itemImageM', '100');        }        if (JRequest::getInt('itemImageM_Height')) {        $imageHeight = JRequest::getInt('itemImageM_Height');        } else {        $imageHeight = $params->get('itemImageM_Height', '115');        }        $handle->image_x = $imageWidth;        $handle->image_y = $imageHeight;        $handle->Process($savepath);

 

Is that right, I just replace the second line.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75444 by BBC
"Crop" an "Fill" are in contradiction, but you can try. I guess it wont work.

It is one or another.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75445 by BBC
You can try to achieve it with statements "if" and "else". But there i can´t help you.

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75446 by juju
Ok, so I delete the line who talk about ratio, ratio_fill, image_background_color and I put the line about ratio_crop, right ?

 

I'll test it tomorrow and I'll see if it's work :)

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75447 by BBC
This works for center crop, tested:

 

$handle->image_resize = true;$handle->image_convert = 'jpg';$handle->jpeg_quality = $params->get('imagesQuality');$handle->file_auto_rename = false;$handle->file_overwrite = true;$handle->file_new_name_body = $filename.'_L';if (JRequest::getInt('itemImageL')) {$imageWidth = JRequest::getInt('itemImageL');} else {$imageWidth = $params->get('itemImageL', '600');}if (JRequest::getInt('itemImageL_height')) {$imageHeight = JRequest::getInt('itemImageL_height');} else {$imageHeight = $params->get('itemImageL_height', '600');}$handle->image_x = $imageWidth;$handle->image_y = $imageHeight;$handle->image_ratio_crop = true;$handle->Process($savepath);

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75448 by BBC
It is OK, taste thing. Don´t complain if "Obama ends in picture without a head". :)

Please Log in or Create an account to join the conversation.

More
14 years 1 week ago #75449 by juju
hihi, thanks ;)

I forget something, if I already have some thumbnail created on my website, how it works when I put this script ?

 

 

 

 

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum