Forum Activity for @ultrajam

SteveX
@ultrajam
04/28/14 06:46:09AM
2,589 posts

Image sizes


Design and Skin Customization

Yes, the width needs to be cropped to maintain the aspect ratio and maintain the max image dimension (switches from width to height or vice versa but is still an small/xlarge/xxlarge image).

Try out my code above (it replaces the if (strpos($_post['crop'], ':')) section at around line 952, and it does do the job perfectly as far as I can see.
SteveX
@ultrajam
04/27/14 03:04:52PM
2,589 posts

Image sizes


Design and Skin Customization

I get the same on my local site though.

The above code fixes it for me.
SteveX
@ultrajam
04/27/14 02:54:37PM
2,589 posts

Image sizes


Design and Skin Customization

No, they both look fine.
SteveX
@ultrajam
04/27/14 02:17:08PM
2,589 posts

Image sizes


Design and Skin Customization

I've been testing that on url images like
/blog/image/blog_image/4/xxlarge/crop=9:18

So far it holds up for blog images of all sizes and aspect ratios and original upload aspect ratio.

The cache problem I was seeing seems to be firefox.
After emptying the jr image cache, ff cache will show a previous version for the same url. You can get around that by changing the image id, size or aspect ratio in the url each time so its always a new url; crop=122:133 crop=122:136 crop=1342:1396 etc
SteveX
@ultrajam
04/27/14 02:01:17PM
2,589 posts

Image sizes


Design and Skin Customization

This seems to work for all images I've tried:

                // Check for an aspect ratio crop
                if (strpos($_post['crop'], ':')) {


//                     // Our aspect ratio crop will come in like 4x3 or 16x9, etc.
//                     list($w, $h) = explode(':', $_post['crop']);
//                     $w = (int) $w;
//                     $h = (int) $h;
//                     // What is our existing ratio?
//                     if ($w > $h) {
//                         $chunk           = round($src_height / $w);
//                         $src_y_offset    = round(($src_height - ($h * $chunk)) / 2);
//                         $new_width       = $_post['width'];
//                         $new_height      = round(($_post['width'] / $w) * $h);
//                         $_post['height'] = $new_height;
//                         $src_height     -= round($src_y_offset * 2);
//                     }
//                     else {
//                         $chunk           = round($src_width / $h);
//                         $src_x_offset    = round(($src_width - ($w * $chunk)) / 2);
//                         $new_height      = $_post['width'];
//                         $new_width       = round(($_post['width'] / $h) * $w);
//                         $_post['width']  = $new_width;
//                         $_post['height'] = $new_height;
//                         $src_width      -= round($src_x_offset * 2);
//                     }

                
                    // Our aspect ratio crop will come in like 4:3 or 16:9, etc.
					$crop = array_filter(explode(':', $_post['crop']));

					$ratio = array(0 => $src_width / $src_height, 1 => $crop[0] / $crop[1]);

					$w = $crop[0];
					$h = $crop[1];
			
					// What is our existing ratio?
					if ($w > $h) {
					
						if ($ratio[0] > $ratio[1]) {
							$width = $src_height * ($w / $h);
							$src_x_offset = ($src_width - $width) / 2;
							$src_width = $width;
						
						}

						else if ($ratio[0] < $ratio[1]) {
							$height = $src_width / ($w / $h);
							$src_y_offset = ($src_height - $height) / 2;
							$src_height = $height;
						}

						$new_width       = $_post['width'];
						$new_height      = round(($_post['width'] / $w) * $h);
						$_post['height'] = $new_height;
						
					}
                    else {

						if ($ratio[0] > $ratio[1]) {
							$width = $src_height * ($w / $h);
							$src_x_offset = ($src_width - $width) / 2;
							$src_width = $width;
						}

						else if ($ratio[0] < $ratio[1]) {
							$height = $src_width / ($w / $h);
							$src_y_offset = ($src_height - $height) / 2;
							$src_height = $height;
						}
						
						$new_height      = $_post['width'];
						$new_width       = round(($_post['width'] / $h) * $w);
						$_post['width']  = $new_width;
						$_post['height'] = $new_height;
							
                    }

                }
                else {
                    // Default auto height/width
SteveX
@ultrajam
04/27/14 06:58:15AM
2,589 posts

Image sizes


Design and Skin Customization

That doesn't seem right at all, all cropped images are distorted regardless of the ratio.
For a 800x601 image (using "large" for 256x256 output):
/blog/image/blog_image/1/large/crop=33:33
|src_height=601 src_width=792 src_y_offset=0 src_x_offset=4|

src_width should be 601 with a src_x_offset of 99

Similar for both landscape and portrait crops 2:1 and 1:2

Also, after emptying the image cache I don't always see a new image being created (the fdebug in the crop section of jrImage/include.php doesn't get triggered). I'm not sure how that image cache is supposed to be working.
SteveX
@ultrajam
04/24/14 10:16:34AM
2,589 posts

Sponsoring a new module


General

Yeah, but not successful news I'm afraid.

From my experiments I'd say sorting and filtering need to be implemented in the skin or the display module. I haven't found a way to add that into other modules (or an aparna module) and skins in a way which makes sense.

The easiest way for you to do this would be to modify your skin templates (if it is a page) or your custom module templates if you want it shown on a profile page.

You'd probably need to add classes or data attributes to filter/sort on to the item (ie add the classes or data attributes to the item row).
SteveX
@ultrajam
04/23/14 03:58:48PM
2,589 posts

Image sizes


Design and Skin Customization

brian:so this is basically just cropping to something that is not a square

When you put it like that it sounds so simple - a linear thread, spiralling on a square.
  164