Advertisement:

Author Topic: A FIX for the Image Resize "white space" issue  (Read 20286 times)

baddad

  • Newbie
  • *
  • Posts: 30
Re: A FIX for the Image Resize "white space" issue
« Reply #30 on: April 15, 2013, 04:35:54 pm »
This is truly a jike! I dont have any idea what to do to get this sorted out.

zombie

  • Sr. Member
  • ****
  • Posts: 376
Re: A FIX for the Image Resize "white space" issue
« Reply #31 on: April 15, 2013, 05:19:37 pm »
I had no time looking over it, either. But if I come up with something, I will share it for sure. This is needed.

Noosa

  • Jr. Member
  • **
  • Posts: 55
Re: A FIX for the Image Resize "white space" issue
« Reply #32 on: April 16, 2013, 04:04:22 pm »
Wanted to share how I addressed this issue.

I'm currently running osclass 3.1.1, was working find on version 3.1 as well.

The basic idea is I just wanted to resize the images getting uploaded rather than crop to a size. This allowes me to use css to handle the images without having to deal with the background color generated when the image is overlayed onto a new image during upload. You can see the end result here: http://duramba.com. As far as sizing the image, that can be done to your taste using css...i.e. fixed aspect ratio for all images.

I haven't tested this with ImageMagick on yet, I'm currently using GD library.

The change i made can be found here:
https://github.com/N00SA/OSC-311/commit/707d88ec6c80324fb1f457cc42b98b4cfb40ba6c

Note:  This is the only change needed to remove the whitespace, 2 lines. Once the whitespace is removed, you are now dealing with a scaled version of the image. Using css, you can crop and fit to your needs.

Hope this helps. If you have an idea to improve upon this, please let me know.
« Last Edit: April 17, 2013, 02:33:29 am by Noosa »

zombie

  • Sr. Member
  • ****
  • Posts: 376
Re: A FIX for the Image Resize "white space" issue
« Reply #33 on: April 16, 2013, 04:16:47 pm »
I think that what we aim to achieve is a center crop to fit the image frame size while avoiding blank spaces, sir.  8)

janaka

  • Newbie
  • *
  • Posts: 28
  • osclass 3.1.1
Re: A FIX for the Image Resize "white space" issue
« Reply #34 on: April 17, 2013, 08:24:17 am »
Hi Noosa,

i tested your fix in osc 3.1.1. nothing changed. also i can't regenerate images. getting invalid CSRF Token error. pls help me on this.


Quote
Wanted to share how I addressed this issue.

I'm currently running osclass 3.1.1, was working find on version 3.1 as well.

The basic idea is I just wanted to resize the images getting uploaded rather than crop to a size. This allowes me to use css to handle the images without having to deal with the background color generated when the image is overlayed onto a new image during upload. You can see the end result here: http://duramba.com. As far as sizing the image, that can be done to your taste using css...i.e. fixed aspect ratio for all images.

I haven't tested this with ImageMagick on yet, I'm currently using GD library.

The change i made can be found here:
https://github.com/N00SA/OSC-311/commit/707d88ec6c80324fb1f457cc42b98b4cfb40ba6c

Note:  This is the only change needed to remove the whitespace, 2 lines. Once the whitespace is removed, you are now dealing with a scaled version of the image. Using css, you can crop and fit to your needs.

Hope this helps. If you have an idea to improve upon this, please let me know.

Noosa

  • Jr. Member
  • **
  • Posts: 55
Re: A FIX for the Image Resize "white space" issue
« Reply #35 on: April 17, 2013, 09:36:48 am »
Hello janaka,

I couldn't replicate the issue you had with regenerating images, I was able to regenerate without issue. There were some issues with CSRF in version 3.1, 3.1.1 addressed them. Let me know what version of osclass you're using so we can rule out if the error is related to 3.1.0.

As far as nothing changing...after the edit to ImageResizer.php, when you upload an image via post new listing do your images still have a background?

To test this, keep in mind i have only edited the ImageResizer class - oc-includes/osclass/classes/ImageResizer.php.

There is a post within the docs, http://doc.osclass.org/Improve_image_upload:_fixes_thumbnails_that_are_too_small as well as other suggested edits. I did not make those changes, just the two lines within the github link i provided. I'm using the default ItemActions.php for osclass 3.1.1.






janaka

  • Newbie
  • *
  • Posts: 28
  • osclass 3.1.1
Re: A FIX for the Image Resize "white space" issue
« Reply #36 on: April 17, 2013, 02:34:43 pm »
Hi Noosa.

Thanks for the fix. I use osclass ver. 3.1.1. yeah i change only oc-includes/osclass/classes/ImageResizer.php this file. i didn't try any other suggest edits. after edit ImageResizer.php i test upload image it get scaled white space removed. now my issue is keep aspect ratio and crop image smooth. i think it can be fix by css.

Still have invalid CSRF Token error when regenerate images.





Silent Reader

  • Jr. Member
  • **
  • Posts: 54
Re: A FIX for the Image Resize "white space" issue
« Reply #37 on: May 03, 2013, 04:33:18 pm »
is there a way to not modif core files?
set function in (current) theme maybe

zombie

  • Sr. Member
  • ****
  • Posts: 376
Re: A FIX for the Image Resize "white space" issue
« Reply #38 on: May 03, 2013, 04:35:20 pm »
is there a way to not modif core files?
set function in (current) theme maybe
No. It is not in the theme.

heman85

  • Jr. Member
  • **
  • Posts: 98
Re: A FIX for the Image Resize "white space" issue
« Reply #39 on: June 05, 2013, 10:27:21 pm »
I do a MERGE of Post and OSCLASS HELP to FIX this on my 3.1.1 Enviroment

I follow those instructions:
http://doc.osclass.org/Improve_image_upload:_fixes_thumbnails_that_are_too_small
But change ony 2nd and 3 $normal_path (Not the Fisrt One "Line 1286")

Then:
Replace the lines in oc-includes/osclass/classes/ImageResizer.php,

Code:
if(($w/$h)<($width/$height)) {
                    //$newW = $width;
                    $newW = ($w > $width)? $width : $w;
                    $newH = $h * ($newW / $w);
                } else {
                    //$newH = $height;
                    $newH = ($h > $height)? $height : $h;
                    $newW = $w * ($newH / $h);
                }
with


if($w >$width) {
                    $newW = $width;
                    $newH = $h * ($newW / $w);
                } else {
                    $newH = $height;
                    $newW = $w * ($newH / $h);
                }

And the white spaces will be less and the thumbs will look better. Hope this works for u guys.
Good Luck

onaldo

  • Jr. Member
  • **
  • Posts: 75
Re: A FIX for the Image Resize "white space" issue
« Reply #40 on: September 14, 2013, 05:22:52 pm »