Announcement: New plug-in SuperSizer

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: Announcement: New plug-in SuperSizer

Post by NikNak »

Thanks Jeremy - I see - I just thought this is what the Fit parameter was going to do.

I seem to be learning a lot from you these days. I'd love to know a bit more about best practice in cmsms and why some things make a difference.

I noticed that callguy mentioned not using too many GCBs, but I don't know why (Im sure he's right). My templates are full of them, as it is the only way I can manage multiple templates containing similar content, without having to make single changes many times - as this is liable to generate mistakes.

Another example - creating a UDT that makes a db query to create an array rather than using a potentially very long winded piece of smarty scripting. Why is one better than the other? The db query could be much simpler to achieve. Is it something to do with the caching?

You dont have to answer these questions - i'm just putting the pieces of the jigsaw together slowly.

Kind regards

Nik
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

>>callguy mentioned not using too many GCBs,

yes mostly for db call as you have to pull that script and it adds time to the process.. same thing with a udt, you will be making a db call before you even had the script to process.. I just prefer not use UDTs unless I have to..

>>I just thought this is what the Fit parameter was going to do.

My interpretation of fit is edge to edge.. so it's fit to width or fit to height and as such is how I wrote it..

I would think what I put below should fit your needs thuo you will want to tune it.. but the idea is to normalize, so for starters you can use supersizer to permanently do a first size on upload, and then this little logic..

I just suggest that you play :D hope this helps.. Cheers -Jeremy
kendo451

Re: Announcement: New plug-in SuperSizer

Post by kendo451 »

I had the same issue and did this:

1. Write a UDT that checks image width vs height against preferred ratio:

Code: Select all

// UDT isportrait
// params image= filepath to image
// if heigth > width returns true

if ( isset($params['image']) ) {
	global $gCms;
	if( !isset($gCms) ) exit;
    $smarty =& $gCms->GetSmarty();
    $config =& $gCms->GetConfig();

	$parts = explode ( ".com/" , $params['image'] );
	$filepath = $config['root_url'].'/'.$parts[1];

	$imageinfo = getimagesize($filepath);
    
    // Idea width / height ratio is 1.5658

	$portait = false;
	if ( ($imageinfo[0] / $imageinfo[1]) <= 1.5658 ) {
		$portrait = true;
	}
	$smarty->assign('isportrait' , $portrait);

	// If image is small nozoom
    
    $nozoom = false;
    if ( ($imageinfo[0] <= 220) || ($imageinfo[1] <= 200 ) ) $nozoom = true;
    $smarty->assign('nozoom' , $nozoom );

}
2. Adapt the supersizer call based on the result:

Code: Select all

{capture assign='imagepath'}{$entry->file_location}/{$image1}{/capture}
                  {isportrait image=$imagepath}
                  {if $isportrait}
                 {supersizer path=$imagepath height=129 passthru=true alt=$entry->product_name|escape:htmlall strip_tags=true error=false}
                 {else}
                 {supersizer path=$imagepath width=202 passthru=true alt=$entry->product_name|escape:htmlall strip_tags=true error=false}
                 {/if}
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Announcement: New plug-in SuperSizer

Post by Jos »

NikNak, I don't know if I have this exacly right (didnt test it), but I think you are looking for something like this?

Code: Select all

{assign var=pathIS value="uploads/imgpath/name.jpg"}
{assign var=sizeIS value=$pathIS|getimagesize}

{if $sizeIS[0]>$sizeIS[1]}{*width > height*}
   {supersizer path=$pathIS height='120' width='90' crop="center,top,`120/$sizeIS[1]*100`"}
{else}
   {supersizer path=$pathIS height='120' width='90' crop="center,top,`90/$sizeIS[0]*100`"}
{/if}
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

:D 50 ways to skin the cat.. awesome examples you guys..
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: Announcement: New plug-in SuperSizer

Post by NikNak »

Thanks very much guys for the examples.

I have one issue remaining now, as all I want (and have ever really wanted) is to centrally crop an image to fit a space completely. This latest version appears to be adding extra image area rather than cropping.

I am now seeing black stripes at the top and bottom of a cropped image, where supersizer has fitted the image inside the required space and padded out the remainder with black. Can I get this to just crop to fit?

Kind regards

Nik
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Announcement: New plug-in SuperSizer

Post by Jos »

NikNak, which code do you use now? Is it a 1 pixel black stripe? that could be a rounding issue.
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: Announcement: New plug-in SuperSizer

Post by NikNak »

Hi Jos
No it was variable from 2 to 10 or more pixels in my examples.

{supersizer path=whatever width=190  height=95 url='true'  crop='true'  protect='false'  assign='thumbpic'}

Thanks
Nik
Attachments
Picture 7.png
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

do me a fav and pass over the images as they are be for they are sized.. I will try something.. but I want to make sure it works there.. that should be working and I don't know why it is not.. I have tested tight long crops like your wanting to do.. so .. hmm, yeah please pass your images so I can recreate the issue...  tk -J
Attachments
2010-07-27_0657.png
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

ok.. here is it.. all fixed and should be ready now to release..

@NikNak please test but here is my test on your images..
http://www.corbensproducts.com/blog/exp ... ikNakcrop4



Please let me know.. cheers -Jeremy

PS.. I'm headed home so I will not be able to get back for a bit..
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: Announcement: New plug-in SuperSizer

Post by NikNak »

Hi Jeremy - that seems to have done the trick.
Thank you again.
Nik
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Ok, :D the new release is out..

http://dev.cmsmadesimple.org/project/files/752

Note if your updating from a release from before (not the last few posts on here) you should double check your params again.

Enjoy and hope you all like it.  Cheers -Jeremy
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am
Location: Berlin

Re: Announcement: New plug-in SuperSizer

Post by nicmare »

i am using the last supersizer version with CMSms 1.6.7 and availbility module 1.7.11.
i call a custom field (type=image) like this:

Code: Select all

<img src="{$file_location}/{$rsrc.fields.myimage.value}" alt="{$rsrc.name}" />
which works pretty good. but now i want to thumbnail it with supersizer, therefore i tried it this way:

Code: Select all

{assign var=imagethumb value=`$file_location`/`$rsrc.fields.myimage.value`}
{supersizer path=$imagethumb width="100"}
and

Code: Select all

{capture assign=imagethumb}{$file_location}/{$rsrc.fields.myimage.value}{/capture}
.
but both methods do not work. i get following error message from supersizer:

Code: Select all

There is a path issue with the orginal image!
Does this look right?
Path:/home/www/myurl.myhost.org/htdocs/yurl.myhost.org/uploads/Availability/resources_1/thumb_346.jpg
what is wrong??
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

I take it that you real path is..

/home/www/myurl.myhost.org/htdocs/uploads/Availability/resources_1/thumb_346.jpg

ie: yank out yurl.myhost.org/?

what does {$file_location} output?
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am
Location: Berlin

Re: Announcement: New plug-in SuperSizer

Post by nicmare »

JeremyBASS wrote: what does {$file_location} output?
http://myurl.myhost.org/uploads/Availab ... esources_1
and $rsrc.fields.myimage.value outputs filename.jpg
maybe it does not work with subdomains?
Locked

Return to “Modules/Add-Ons”