Hy!

I am using a Total gallery formatter for my gallery of pictures. Now I want to use some image styles for scaling the images to best fit the carousel and also to fit the bottom slide pictures. So it should fit the height or width, but it shouldn't exceed the area, so picture should be totally visible. Only pictures that are smaller than width or height of the area, shouldn't be scaled. I tried many modules to change the scale but it's just not working as I want. I also tried PHP action in ImageCache Actions module, but PHP is not executed at all.. don't know why really..
Do you know what is the best idea to solve this?

For example I want to run a code similar to this one: http://laravel.io/bin/wJa3e because it calculates the image size properly. Of course I want to keep the aspect ratio as original.

Thank you!

Comments

cmsMinds’s picture

For this you need to create new image styles with image style name

Please follow this path :

wthen logged in go to admin configuration

config->media->image-styles.

there will be different styles like Resize, scale, crop etc..

you need to add two properties: first Resize and then scale.

this should help you.

sasos90’s picture

But resizing doesn't work :) Resize ignores the aspect ratio. I don't want to lose aspect ratio.

Jaypan’s picture

Then you want 'scale'.

sasos90’s picture

Yes but I used Scale. The scaling doesn't work because I have some max-width and max-height (500×300) which I don't want to exceed. So If I have some long width banner, and I scale it on the height to 300px, the width will still be over 500. Then I need to scale the width again. But that's just not working with Scale (500×300). I also tried to add effects: Scale 500 and Scale 300 seperately .. but that's also not working.
That Scale 500×300 works just like resize. It lose the aspect ratio.

Any idea?

Jaypan’s picture

Scale and crop

sasos90’s picture

I don't want to crop anything :)
Again, you can see in my first post (http://laravel.io/bin/wJa3e) the code that is working for scaling to best fit size so just scaling is like putting the max-width and max-height with auto width for example in the css. But that's not that easy, otherwise I would do that already. The picture must be of 300 height OR 500 width (if it's bigger then this size, otherwise just leave it and position it in the middle).
I see it's kinda tricky.

cfox612’s picture

You should be able to apply an image style to scale it to a max of 300x500 and not allow upsizing. That's what scale does, it respects the aspect ration and holds it image to a max of 500 wide or 300 high. I tested locally setting up a new image style with scale 300x500 and not allow upsizing. Images smaller than the ratio remained untouched. Larger images were resized appropriately.

Image #1 was 650x550 resized to 300x355 (300 height max)
Image #2 was 450x250 resized to 300x167 (300 height max)
Image #3 was 650x650 resized to 300x300
Image #4 was 250x650 resized to 192x500 (500 width max)
Image #5 was 250x450 and remained the same

Is that not what you're trying to accomplish?

sasos90’s picture

Actually now I see what is the problem. The pictures are really resized properly. But my total gallery formater just put the width and height to the pictures which stretches them wide. Thank you! :)