Smart Image Processor PHP 2 Support Product Page

This topic was archived

Resize for Portrait or Landscape

Asked 24 Oct 2007 23:20:57
1
has this question
24 Oct 2007 23:20:57 Nick B posted:
I want a user to be able to upload an image and have it resize for portrait or landscape. Example:
Original Image Portrait: 600x800
Original Image Landscape: 800x600
MAXIMUM SIZE WIDTH OR HEIGHT: 640x640
Must constrain proportions
Resized Image Portrait: 480x640
Resized Image Landscape: 640x512

Make sense? How do I do it?

Edited by - nbostic on 25 Oct 2007 00:42:06

Replies

Replied 26 Oct 2007 03:41:48
26 Oct 2007 03:41:48 Nick B replied:
Any luck "tech support"?
Replied 29 Oct 2007 17:33:42
29 Oct 2007 17:33:42 Kiril Iliev replied:
Hi Nick,

Yes, you can do that. We will show you a simple example how to do it. Firstly, you have to add the following code on top of your page after inserting Pure PHP Upload and Smart Image Processor for a single form:

<pre id=code><font face=courier size=2 id=code>
&lt;?php
if(isset($_POST["imagetype"]))
{
switch ($_POST["imagetype"])
{
case "Portrait" : $h = 480;
$w = 640;
break;
case "Landscape": $h = 640;
$w = 512;
break;
}
}
else
{
$h = 480;
$w = 640;
}
?&gt;
</font id=code></pre id=code>

Do not forget to change the following variable in SIP code block from
<pre id=code><font face=courier size=2 id=code>$sipp2-&gt;resize(640, 480, false);</font id=code></pre id=code> to <pre id=code><font face=courier size=2 id=code>$sipp2-&gt;resize($h, $w, false);</font id=code></pre id=code>

Final designer decision is to make a select type where $_POST["imagetype"] variable is selected by the user. I have decided to make it with a list:

<pre id=code><font face=courier size=2 id=code>
&lt;select name="imagetype" id="imagetype"&gt;
&lt;option value="Portrait"&gt;Portrait&lt;/option&gt;
&lt;option value="Landscape"&gt;Landscape&lt;/option&gt;
&lt;/select&gt;
</font id=code></pre id=code>
Of course feel free to make it with another method - radio buttons for example.

DMX Zones Support Team

Reply to this topic