Page 1 of 1

[SOLVED] CGSmartImage max width and height

Posted: Mon Jan 16, 2012 6:49 pm
by McF
Hello,

I saw caution "Image processing functions are deprecated..." in Products module and started to use CGSmartImage module.

Great image processing module.
But I have problems with setting maximum width or height of re-sized photo...

Code: Select all

{capture assign=artwork}{$entry->file_location}/{$entry->fields.artwork->value}{/capture}
{CGSmartImage src=$artwork filter_resizetofit="100,100"}
{CGSmartImage src=$artwork filter_resize="w,100" filter_resize="h,100"}
{CGSmartImage src=$artwork width="100" height="100"}
{cgsi_convert max_width="100" max_height="100"}{CGSmartImage src=$artwork}{/cgsi_convert} 
None of above is not working as I need. Last approach do not show image at all.

McF

Re: CGSmartImage max width and height

Posted: Wed Jan 18, 2012 6:09 pm
by McF
Solved.

Using PHP function getimagesize I get width and height. Then I compare width with height and use CGSmartImage depending on which measurement is greater.

Code: Select all

{capture assign=image}{$entry->file_location}/{$entry->fields.image->value}{/capture}
{assign var="image_atr" value=$image|getimagesize}
{if $image_atr[0] gt $image_atr[1]}
  {CGSmartImage src=$image filter_resize="w,100"}
{else}
  {CGSmartImage src=$image filter_resize="h,100"}
{/if}

Re: CGSmartImage max width and height

Posted: Tue Jan 31, 2012 1:19 pm
by dmgd
Thanks I need this. I tried the tag {cgsi_convert} and could never get it to work.