<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SCRIPT] Resize image mantenendo proporzioni]]></title><description><![CDATA[<p dir="auto">Ciao a tutti,</p>
<p dir="auto">mi dite cosa sbaglio in questo script ?</p>
<p dir="auto">[php]<br />
list($ihwidth,$ihheight) = explode('x',$grandezza);<br />
//IMPOSTO UN MASSIMALE PER LE IMMAGINI<br />
$altezzamassima = "270";<br />
$larghezzamassima = "240";</p>
<p dir="auto">if($ihwidth &gt; $larghezzamassima &amp;&amp; $ihheight &lt;= $altezzamassima) {<br />
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;<br />
$ihwidth1 = $ihwidth - $ihwidthprovvisorio;</p>
<p dir="auto">$prendimolapercentualetolta = ($ihwidthprovvisorio/$ihwidth)*100;<br />
$ihheightprovv =($ihheight * $prendimolapercentualetolta)/100;<br />
$ihheight1 = round($ihheight - $ihheightprovv);<br />
}</p>
<p dir="auto">if($ihheight &gt; $altezzamassima &amp;&amp; $ihwidth &lt;= $larghezzamassima) {<br />
$ihheightprovvisorio = $ihheight - $altezzamassima;<br />
$ihheight1 = $ihheight - $ihheightprovvisorio;</p>
<p dir="auto">$prendimolapercentualetolta2 = ($ihheightprovvisorio/$ihwidth)*100;<br />
$ihwidthprovv =($ihwidth * $prendimolapercentualetolta2)/100;<br />
$ihwidth1 = round($ihwidth - $ihwidthprovv);</p>
<p dir="auto">}</p>
<p dir="auto">if($ihheight &gt; $altezzamassima &amp;&amp; $ihwidth &gt; $larghezzamassima) {<br />
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;<br />
$ihheightprovvisorio = $ihheight - $altezzamassima;</p>
<p dir="auto">if($ihwidthprovvisorio &gt;= $ihheightprovvisorio) {<br />
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;<br />
$ihwidth1 = $ihwidth - $ihwidthprovvisorio;<br />
$prendimolapercentualetolta = ($ihwidthprovvisorio/$ihwidth)*100;<br />
$ihheightprovv =($ihheight * $prendimolapercentualetolta)/100;<br />
$ihheight1 = round($ihheight - $ihheightprovv);</p>
<p dir="auto">}</p>
<p dir="auto">else if($ihwidthprovvisorio &lt; $ihheightprovvisorio){<br />
$ihheightprovvisorio = $ihheight - $altezzamassima;<br />
$ihheight1 = $ihheight - $ihheightprovvisorio;<br />
$prendimolapercentualetolta2 = ($ihheightprovvisorio/$ihwidth)*100;<br />
$ihwidthprovv =($ihwidth * $prendimolapercentualetolta2)/100;<br />
$ihwidth1 = round($ihwidth - $ihwidthprovv);<br />
}</p>
<p dir="auto">}<br />
else if($ihwidth &lt;= $larghezzamassima &amp;&amp; $ihheight &lt;= $altezzamassima) {<br />
$ihwidth1 = $ihwidth;<br />
$ihheight1 = $ihheight;<br />
}[/php]</p>
<p dir="auto">Io vorrei solo ricreare l'immagine senza perdere il ratio..</p>
<p dir="auto">Avete idee?</p>
]]></description><link>https://connect.gt/topic/157873/script-resize-image-mantenendo-proporzioni</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Apr 2026 16:53:12 GMT</lastBuildDate><atom:link href="https://connect.gt/topic/157873.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Oct 2011 11:49:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Mon, 21 Jul 2014 15:12:32 GMT]]></title><description><![CDATA[<p dir="auto">Ciao,</p>
<p dir="auto">quello script è davvero di base per il caricamento delle immagini..<br />
Dovresti prima recuperare le dimensioni magari in questo modo:<br />
[PHP]<br />
//recupero altezza e larghezza</p>
<p dir="auto">$imagesize = @getimagesize($nome_file_temporaneo);<br />
$ihwidth= $imagesize[0];<br />
$ihheight= $imagesize[1];</p>
<p dir="auto">//IMPOSTO UN MASSIMALE PER LE IMMAGINI<br />
$am = "150";<br />
$lm = "150";</p>
<p dir="auto">if($ihwidth &gt; $lm or $ihheight &gt; $am) {<br />
$eliminarel = $ihwidth - $lm;<br />
$eliminarea = $ihheight - $am;<br />
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel<em>100)/$ihwidth);<br />
$ihw = round(($ihwidth/100)</em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)<em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea</em>100)/$ihheight);<br />
$ihw = round(($ihwidth/100)<em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)</em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
}<br />
else {<br />
$ihwidth1 = $ihwidth;<br />
$ihheight1 = $ihheight;<br />
}</p>
<p dir="auto">//se l'immagine sarà da ridimensionare, verrà ridimensionata grazie allo script che calcola le giuste variazioni</p>
<p dir="auto">$thumb2 = imagecreatetruecolor($ihwidth1, $ihheight1);<br />
imagecopyresized($thumb2, $source, 0, 0, 0, 0, $ihwidth1, $ihheight1, $ihwidth, $ihheight);<br />
$anteprima2 = "nomefoto";<br />
imagejpeg($thumb2, "percorso della foto".$anteprima2, 75);</p>
<p dir="auto">[/PHP]</p>
<p dir="auto">Ovviamente lascio a te mettere i controlli ecc.. Il codice è vecchio, ma grosso modo è così che funziona.</p>
<p dir="auto">Ciao,<br />
M.</p>
]]></description><link>https://connect.gt/post/1025478</link><guid isPermaLink="true">https://connect.gt/post/1025478</guid><dc:creator><![CDATA[sovietiko]]></dc:creator><pubDate>Mon, 21 Jul 2014 15:12:32 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Wed, 02 Apr 2014 15:50:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://connect.gt/uid/833">@Sovietiko</a> said:</p>
<blockquote>
<p dir="auto">C'erano 2 errori, questo è perfetto:</p>
</blockquote>
<p dir="auto">[php]<br />
//IMPOSTO UN MASSIMALE PER LE IMMAGINI<br />
$am = "150";<br />
$lm = "150";</p>
<p dir="auto">if($ihwidth &gt; $lm or $ihheight &gt; $am) {<br />
$eliminarel = $ihwidth - $lm;<br />
$eliminarea = $ihheight - $am;<br />
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel<em>100)/$ihwidth);<br />
$ihw = round(($ihwidth/100)</em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)<em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea</em>100)/$ihheight);<br />
$ihw = round(($ihwidth/100)<em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)</em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
}<br />
else {<br />
$ihwidth1 = $ihwidth;<br />
$ihheight1 = $ihheight;<br />
}<br />
[/php]</p>
<p dir="auto">e in questo script dove lo dovrei collocare ? /forum/scripting-e-risorse-utili/95013-tutorial-come-caricare-un-immagine-su-database-mysql.html<br />
:():</p>
]]></description><link>https://connect.gt/post/1025481</link><guid isPermaLink="true">https://connect.gt/post/1025481</guid><dc:creator><![CDATA[ilgrizly]]></dc:creator><pubDate>Wed, 02 Apr 2014 15:50:53 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Wed, 01 Jan 2014 10:58:50 GMT]]></title><description><![CDATA[<p dir="auto">Buongiorno a tutti....sono un neofita e vorrei sapere all'interno di quale file devo aggiungere il codice. Utilizzo lo script:<br />
'<a href="http://giorgiotave.it/forum/scripting-e-risorse-utili/95013-tutorial-come-caricare-un-immagine-su-database-mysql.html" rel="nofollow ugc">giorgiotave.it/forum/scripting-e-risorse-utili/95013-tutorial-come-caricare-un-immagine-su-database-mysql.html</a>'</p>
<p dir="auto">Ringrazio e Buon Anno!<br />
Marco</p>
]]></description><link>https://connect.gt/post/1025488</link><guid isPermaLink="true">https://connect.gt/post/1025488</guid><dc:creator><![CDATA[mad02]]></dc:creator><pubDate>Wed, 01 Jan 2014 10:58:50 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Fri, 14 Oct 2011 19:47:55 GMT]]></title><description><![CDATA[<p dir="auto">Fatto, grazie a nome della community. <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=4as8rolt52f" class="not-responsive emoji emoji-android emoji--wink" title=";)" alt="😉" /></p>
]]></description><link>https://connect.gt/post/1025476</link><guid isPermaLink="true">https://connect.gt/post/1025476</guid><dc:creator><![CDATA[samyorn]]></dc:creator><pubDate>Fri, 14 Oct 2011 19:47:55 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Fri, 14 Oct 2011 19:33:29 GMT]]></title><description><![CDATA[<p dir="auto">[...]</p>
<p dir="auto">Certo! Spero sarà utile a tutti! <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=4as8rolt52f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" title=":)" alt="🙂" /></p>
]]></description><link>https://connect.gt/post/1025477</link><guid isPermaLink="true">https://connect.gt/post/1025477</guid><dc:creator><![CDATA[sovietiko]]></dc:creator><pubDate>Fri, 14 Oct 2011 19:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Fri, 14 Oct 2011 19:27:08 GMT]]></title><description><![CDATA[<p dir="auto">Ciao Sovietiko,<br />
ottimo script, complimenti.<br />
Con il tuo permesso mi piacerebbe inserirlo nella sezione script utili. <img src="https://connect.gt/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=4as8rolt52f" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" title=":)" alt="🙂" /></p>
]]></description><link>https://connect.gt/post/1025475</link><guid isPermaLink="true">https://connect.gt/post/1025475</guid><dc:creator><![CDATA[samyorn]]></dc:creator><pubDate>Fri, 14 Oct 2011 19:27:08 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Fri, 14 Oct 2011 12:48:39 GMT]]></title><description><![CDATA[<p dir="auto">C'erano 2 errori, questo è perfetto:</p>
<p dir="auto">[php]<br />
//IMPOSTO UN MASSIMALE PER LE IMMAGINI<br />
$am = "150";<br />
$lm = "150";</p>
<p dir="auto">if($ihwidth &gt; $lm or $ihheight &gt; $am) {<br />
$eliminarel = $ihwidth - $lm;<br />
$eliminarea = $ihheight - $am;<br />
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel<em>100)/$ihwidth);<br />
$ihw = round(($ihwidth/100)</em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)<em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea</em>100)/$ihheight);<br />
$ihw = round(($ihwidth/100)<em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)</em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
}<br />
else {<br />
$ihwidth1 = $ihwidth;<br />
$ihheight1 = $ihheight;<br />
}<br />
[/php]</p>
]]></description><link>https://connect.gt/post/1025473</link><guid isPermaLink="true">https://connect.gt/post/1025473</guid><dc:creator><![CDATA[sovietiko]]></dc:creator><pubDate>Fri, 14 Oct 2011 12:48:39 GMT</pubDate></item><item><title><![CDATA[Reply to [SCRIPT] Resize image mantenendo proporzioni on Fri, 14 Oct 2011 07:42:03 GMT]]></title><description><![CDATA[<p dir="auto">Se a qualcuno dovesse servire, ho ottimizzato lo script:</p>
<p dir="auto">[php]<br />
list($ihwidth,$ihheight) = explode('x',$grandezza);<br />
//IMPOSTO UN MASSIMALE PER LE IMMAGINI<br />
$am = "270";<br />
$lm = "240";<br />
if($ihwidth &gt; $lm or $ihheight &gt; $am) {<br />
$eliminarel = $ihwidth - $lm;<br />
$eliminarea = $ihheight - $am;<br />
if (($elimnarel - $eliminarea) &gt; ($eliminarea - $eliminarel)) { $perc = ($eliminarel<em>100)/$ihwidth;<br />
$ihw = round(($ihwidth/100)</em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)<em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
else if (($elimnarel - $eliminarea) &lt; ($eliminarea - $eliminarel)) { $perc = ($eliminarea</em>100)/$ihheight;<br />
$ihw = round(($ihwidth/100)<em>$perc);<br />
$ihwidth1 = $ihwidth-$ihw;<br />
$ihh = round(($ihheight/100)</em>$perc);<br />
$ihheight1 = $ihheight - $ihh;<br />
}<br />
}<br />
else {<br />
$ihwidth1 = $ihwidth;<br />
$ihheight1 = $ihheight;<br />
}[/php]</p>
<p dir="auto">Funziona alla perfezione dato che calcola le %.</p>
<p dir="auto">Saluti.</p>
]]></description><link>https://connect.gt/post/1025474</link><guid isPermaLink="true">https://connect.gt/post/1025474</guid><dc:creator><![CDATA[sovietiko]]></dc:creator><pubDate>Fri, 14 Oct 2011 07:42:03 GMT</pubDate></item></channel></rss>