Different thumbs for landscape and portrait orientation

ok, if I look at thumb($image, $params = array(), $obj = true), then you may be right, if I look in the examples.
But I find no info there, that the $params = array() needs to have width as the first parameter.
That could be added…

Well, it’s actually the way parameters work, if you have more than one, their order must be obeyed, otherwise the method would not know what is what.

1 Like

@texnixe:

Thank you very much, now I know, why this did not run on an older version of another dev website.

HeinerEF

Well, I think my explanation is outright wrong in this case, because this is an array of named parameters, you can leave some out. So the reason must be different, need to check the source code what might be causing this.

Edit: Thinking before writing can help sometimes …:frowning:

1 Like

hey thank you so much for all your responses! @texnixe i tried your edited code above (2nd entry) and @anon77445132 s first code but it would not work out: @texnixe is seems that just the thumbs are not generated, but pictures are showing… (original size) and @anon77445132 : nothing at all is showing :frowning:

i need to try @lukasbestle s hint on changing to mamp this weekend and i’ll post my experience!

My intention is to first reduce the overall size of the image and then crop it. My understanding of cropping is, that if i had an image 1000 x 750 px and it would be cropped to a square of 200px, 800px in width and 550px in height will not be visible- what i want is the big image to be reduced in size first and then crop it to its longest outline,

i hope this is a clear description(?)

best wishes guys!

EDIT: oh and i’m using kirby 2.3.1

That’s probably a misunderstanding, if you crop it, it will resize and crop in one go, that is, only remove those parts of the image that don’t fit into the format after resizing.

I think what @fptt means is that if you have an image that is 1200600 and you crop it to 200200, then you lose a lot more of the original image than if you reduced it to 400*200 before cropping.
At least that’s my understanding !

@Thiousi: As I said, that is a misunderstanding.

Then the misunderstanding is mine too! Glad to hear it :slight_smile:

You can simply test this on the starterkit (projects template) to see for yourself.

We start with the original image, then resize it, while preserving its original aspect ratio. The third example is a direct crop.

<?php foreach($page->children() as $project): ?>
  <div class="grid-item">
      <?php if($image = $project->images()->sortBy('sort', 'asc')->first()): ?>
          <img class="project-image" src="<?php echo $image->url() ?>" alt="<?php echo $project->title()->html() ?>" >
          <img class="project-image" src="<?php echo $image->resize(300)->url() ?>" alt="<?php echo $project->title()->html() ?>" >
          <img class="project-image" src="<?php echo $image->crop(200)->url() ?>" alt="<?php echo $project->title()->html() ?>" >
  <?php endif ?>
</div>

The cropped image and the resized one both have the same height, the cropped one is cropped on both sides to make it square. It’s not like cutting out 200*200px from the original image.

hey it worked now! i changed the thumbsdriver in my config from ‘im’ to ‘gd’ - i remember that i have changed this a little while ago (i think with kirby 2.1) because the docs said that ‘im’ would be faster…

maybe there is any explenation for this…

anyway thank you all for you wonderful help!!
cheers!

1 Like

So you don’t have ImageMagick installed then? That explains it all. Glad you figured it out …:slight_smile: