Advertisement:

Author Topic: Image Resize with Smart Offset and No White Space.  (Read 10991 times)

Aurora

  • Newbie
  • *
  • Posts: 47
Re: Image Resize with Smart Offset and No White Space.
« Reply #30 on: March 25, 2015, 02:05:40 am »
Hello everyone
Help me, I'm new and I do not understand a lot of the program, I do not like the pictures with different sizes and with white borders, I saw that you have solved the problem.
I have the theme Modern Plus 1.0 and would like to make changes .... but I'm afraid to combine trouble.
Do you have a complete file to replace my so that I do not break anything?
Sorry for writing but I'm using traslator
Aurora

Aurora

  • Newbie
  • *
  • Posts: 47
Re: Image Resize with Smart Offset and No White Space.
« Reply #31 on: March 27, 2015, 03:23:38 pm »
 :'( :'( :'( :'( :'( :'( :'(

Aurora

  • Newbie
  • *
  • Posts: 47
Re: Image Resize with Smart Offset and No White Space.
« Reply #32 on: April 08, 2015, 09:08:11 pm »
Hello.
Even if you do not remove the spaces ..... at least reduce them

Aurora

  • Newbie
  • *
  • Posts: 47
Re: Image Resize with Smart Offset and No White Space.
« Reply #33 on: April 28, 2015, 07:28:58 pm »
I made a simple request, but it's possible that in this forum NOT NO ONE HELPS YOU ??
I just have to recognize that Cartagena68 was the only one who helped me !!!
Or just because I do not speak and write in your own language and I have to help with a translator ???

Aficionado

  • Guest
Re: Image Resize with Smart Offset and No White Space.
« Reply #34 on: April 29, 2015, 01:19:18 am »
These forums are FULL of replies and help.

If you get no reply could mean 2 things: (a) the answer is already posted in the forums and you have to search or (b) nobody knows the answer.


Aurora

  • Newbie
  • *
  • Posts: 47
Re: Image Resize with Smart Offset and No White Space.
« Reply #35 on: May 02, 2015, 12:54:10 pm »
These forums are FULL of replies and help.

If you get no reply could mean 2 things: (a) the answer is already posted in the forums and you have to search or (b) nobody knows the answer.

Yes, that will be true in the forum you can find what you seek, but it is true that being a new and more do not speak your language, I have my problems, thank goodness that Cartagena has been and is still very useful help, I can not say how the other.

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: Image Resize with Smart Offset and No White Space.
« Reply #36 on: May 12, 2015, 10:53:23 am »
It will remove whitespace and crop 1/2 on width or 1/4 top & 3/4 bottom on height.

In ImageResizer.php use this calculation.

Code: [Select]
                $w = imagesx($this->im);
                $h = imagesy($this->im);
                $newW = ($w > $width)?  $width  : $w;
                $newH = ($h > $height)? $height : $h;
               
                if(($w/$h)<($width/$height)) {
                  //$newW = $width;
                  $cropedW = $w;
                  $cropedH = ($w > $width)? ($w * $height / $width) : $newH;
                  $offsetx = 0;
                  $offsety = ($h - $cropedH) / 4; 
                } else {
                  //$newH = $height;
                  $cropedW = ($h > $height)? ($h * $width / $height) : $newW;
                  $cropedH = $h;
                  $offsetx = ($w - $cropedW) /2;
                  $offsety = 0;
                }

                $newIm = imagecreatetruecolor($width,$height);//$newW, $newH);
                imagealphablending($newIm, false);
                $colorTransparent = imagecolorallocatealpha($newIm, 255, 255, 255, 127);
                imagefill($newIm, 0, 0, $colorTransparent);
                imagesavealpha($newIm, true);
                imagecopyresampled($newIm, $this->im, (($width-$newW)/2), (($height-$newH)/2), $offsetx, $offsety, $newW, $newH, $cropedW, $cropedH);
                imagedestroy($this->im);

                $this->im = $newIm;

In ItemActions.php

Change 
Code: [Select]
     ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path);
TO
Code: [Select]
     ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path);
twice.

And you can adjust your image/thumbnail size in oc-admin page.

Hello. This fix works with bender theme? Thanks

weblab

  • Newbie
  • *
  • Posts: 9
Re: Image Resize with Smart Offset and No White Space.
« Reply #37 on: May 15, 2015, 09:43:21 pm »
It is working with the latest version osclass?
« Last Edit: June 25, 2015, 07:10:19 pm by weblab »

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image Resize with Smart Offset and No White Space.
« Reply #38 on: July 06, 2019, 02:29:02 pm »
Hello,
Does anyone know a solution to this issue on osclass 3.8.0?

thanks