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 »

Hi Jeremy

I still cannot get the scaling to operate prior to cropping. I believe this is the fit="true" parameter. Is this working in your tests?

Kind regards

Nik
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

I'm fixing it now in fact.. I did remove the need for fit=true on the crop.. you'll just need to go crop=true and that is it.. it'll auto fit.. it's almost working.. a little squeeze on it atm but I'll have that fix later today.  Cheers –Jeremy
kendo451

Re: Announcement: New plug-in SuperSizer

Post by kendo451 »

Your latest version still outputs the error, but it also outputs the full sized picture if passthru=true.  Here is the code followed by the result.  I suggest that you add a test to your test page where you feed it a full url path and see what output is given.

I created this little example so you can see what input gives what output.  I am feeding supersizer a variable $imagepath.  This code outputs $imagepath as an HTML comment, and then feeds it to supersizer and you can see supersizer's output.

Code in product summary template:

Code: Select all

 {if $thumb !=''}
 {capture assign='imagepath'}{$entry->file_location}/{$thumb}{/capture}
 <img src="{$imagepath}" alt="{$entry->product_name}" width="202" height="129" />
 {else}
 {capture assign='imagepath'}{$entry->file_location}/{$image1}{/capture}
 <!-- $imagepath = {$imagepath} /-->
 {/if}
 {supersizer path=$imagepath width=202 height=129 crop='true' passthru='true' alt=$entry->product_name strip_tag=true}
Outputs this:

Code: Select all

 <!-- $imagepath = http://new.vasesrus.com/uploads/Products/product_20/1907.jpg /-->
  <br/><font color="#FF0000">There is a path issue with the orginal image!</font><br/><strong>Does this look right?<br/>Path:</strong>/var/www/vhosts/vasesrus.com/subdomains/new/httpdocs/new.vasesrus.com<br/><img src="http://new.vasesrus.com/uploads/Products/product_20/1907.jpg?"    alt="9" Classic Urn"    />
Last edited by kendo451 on Wed Jul 21, 2010 5:40 pm, edited 1 time in total.
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Man that is odd.. guess I need to work it some more.. See I have it working on my test, if you recall here..

http://forum.cmsmadesimple.org/index.ph ... #msg217487

I will just try a didferent trick then as it only seem to be working 50% of the time :/ 100% for me 0% for you :D



now for the error with passthru, you can do this.. add error=false 

{supersizer path=$imagepath width=202 height=129 crop='true' passthru='true' error=false alt=$entry->product_name strip_tags=true}

then you'll only get the passthru.

I'll check it out in a few hours from now.. I need to finish a few jobs.. tk for getting back.. -J
kendo451

Re: Announcement: New plug-in SuperSizer

Post by kendo451 »

Some confusion over strip_tag or strip_tags.  I tried it both ways with the same result.
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

it's strip_tags .. did I put strip_tag some where.. :? that would be me to do that .. lol... so the code.. see it is tripling up on the removal.. it should pick yours up and work..

Code: Select all


	if($strip_tags){
		$matches = array(); 
		if (preg_match('#<(.*?)src="(.*?)"(.*?)/>#', $path, $matches)) { 
		   $path =  $matches[2]; 
		}
		if (preg_match('#[http|https]://(.*?)/(.*?)#', $path, $matches)) { 
		   $path =  $matches[1]; 
		}
		if ((substr($path, 0,5))=="https"){$L=strlen($config['ssl_url']);$path = substr_replace($path, '', 0, $L);}	
		if ((substr($path, 0,4))=="http"){$L=strlen($config['root_url']);$path = substr_replace($path, '', 0, $L);}
		
	}


I'll take a look at it late today.. I have the fit crop to put in so I'll just do both at once.. and put this baby to bed :D.. tk -J
kendo451

Re: Announcement: New plug-in SuperSizer

Post by kendo451 »

I just pasted your if($striptags){...} bit in my plugin in place of the routine that was there, but it still doesn't work for me.

Could it be because I am using a subdomain and your preg replace isn't catching it?

http://new.vasesrus.com
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Could it be because I am using a subdomain and your preg replace isn't catching it?

http://new.vasesrus.com
No it shouldn't unless somehow the subdomain is not in the $config['root_url'] .. then may-be.. ok try this please..

Code: Select all

	if($strip_tags){
		if (preg_match('#<(.*?)src="(.*?)"(.*?)/>#', $path, $matches)) { 
		   $path =  $matches[2]; 
		}
		if ((substr($path, 0,5))=="https"){$L=strlen($config['ssl_url']);$path = substr_replace($path, '', 0, $L);}	
		if ((substr($path, 0,4))=="http"){$L=strlen($config['root_url']);$path = substr_replace($path, '', 0, $L);}
		$matches = array(); 
		if (preg_match('#[http|https]://(.*?)/(.*?)#', $path, $matches)) { 
		   $path =  $matches[0]; 
		}
	}

kendo451

Re: Announcement: New plug-in SuperSizer

Post by kendo451 »

That last change appears to have corrected the problem, Jeremy.  I swapped out the code again and it works correctly.
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

ok.. well guess the order produced the stability issue here.. I will put a full file up with the changes and the new crop to fit code.. I have also worked to reduce the size some so hopefully I can make it a 1-3kb smaller.. I hope :D .. bbiab -J
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Here it is.. the pre-release... :D please test. but the crop to fit is in.. crop choice with scale is in... and refinment and tightening of code with fixes to the strip_tags.

the crop to fit is just crop=true that is it.. no need to use the fit param..

Please let me know if there is any issues but it'll be release in a day or so.. Cheers -Jeremy
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
The new version crops in the center now when you use crop='true'.
Are you able to scale the image to the largest of the desired width and height and then crop to the area specified, rather than to crop the original image without any scaling at all?
For example, if you have a tall portrait image with someone's head at the top, but you wanted to crop this to a landscape format, but wanted to crop into the top of the portrait picture to maintain the head as the focus, can you do this? ie scale, then crop the result rather than crop without any scaling.

Kind regards

Nik
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Um that sounds like you want to use the crop like this.. crop='center,top,50'  what 50 is 50% of the original image... That has scale in it.. the thing is if it's fit then the scale has to be done for you.  If you want to scale you have to tell if from where but as it's scale there is no way to fit it as it will not match the scale you want..

What you want to do with the scale is pic what you determine to be the safe % ie 50% would almost always be safe.. as long as you don't go under the aspect ratio

Hope that makes sense.. Cheers -Jeremy
Last edited by JeremyBASS on Mon Jul 26, 2010 5:19 pm, edited 1 time in total.
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 - I think I understand.

From what I can gather, a user would need to work out height and width of each original image and work out the percentage scaling required to fit the desired output, before calling Supersizer to do the manipulation. A guess of 50% would surely produce a very different outcome for a 1000px image vs a 200px image.

I'm sure I would need to make a UDT to work this out for me rather than guess a percentage.

thanks again

Nik
JeremyBASS

Re: Announcement: New plug-in SuperSizer

Post by JeremyBASS »

Well a udt is not needed , as it hits the db too... I'd think there are smarty based examples  below that will help you.. I'd see that you could set up a filte of sorts to fit your needs.. but here is a thought

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

{if $widthIS[0]>'1000'}
{supersizer path=$pathIS width='100' crop="center,top,25"}
{else if $widthIS[0]>'750'}
{supersizer path=$pathIS width='100' crop="center,top,35"}
{else if $widthIS[0]>'500'}
{supersizer path=$pathIS width='100' crop="center,top,50"}
{else if $widthIS[0]>'300'}
{supersizer path=$pathIS width='100' crop="center,top,75"}
{/if}
as you can see I can't do that in the script as what if some one wants left center.. etc.. Hope this helps.. Cheers -Jeremy
Locked

Return to “Modules/Add-Ons”