<?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>
<pre><code class="language-php">list($ihwidth,$ihheight) = explode('x',$grandezza);
//IMPOSTO UN MASSIMALE PER LE IMMAGINI
$altezzamassima = "270";
$larghezzamassima = "240";

if($ihwidth &gt; $larghezzamassima &amp;&amp; $ihheight &lt;= $altezzamassima) {
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;
$ihwidth1 = $ihwidth - $ihwidthprovvisorio;

$prendimolapercentualetolta = ($ihwidthprovvisorio/$ihwidth)*100;
$ihheightprovv =($ihheight * $prendimolapercentualetolta)/100;
$ihheight1 = round($ihheight - $ihheightprovv);
}

if($ihheight &gt; $altezzamassima &amp;&amp; $ihwidth &lt;= $larghezzamassima) {
$ihheightprovvisorio = $ihheight - $altezzamassima;
$ihheight1 = $ihheight - $ihheightprovvisorio;

$prendimolapercentualetolta2 = ($ihheightprovvisorio/$ihwidth)*100;
$ihwidthprovv =($ihwidth * $prendimolapercentualetolta2)/100;
$ihwidth1 = round($ihwidth - $ihwidthprovv);

}

if($ihheight &gt; $altezzamassima &amp;&amp; $ihwidth &gt; $larghezzamassima) {
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;
$ihheightprovvisorio = $ihheight - $altezzamassima;

if($ihwidthprovvisorio &gt;= $ihheightprovvisorio) {
$ihwidthprovvisorio = $ihwidth - $larghezzamassima;
$ihwidth1 = $ihwidth - $ihwidthprovvisorio;
$prendimolapercentualetolta = ($ihwidthprovvisorio/$ihwidth)*100;
$ihheightprovv =($ihheight * $prendimolapercentualetolta)/100;
$ihheight1 = round($ihheight - $ihheightprovv);

}

else if($ihwidthprovvisorio &lt; $ihheightprovvisorio){
$ihheightprovvisorio = $ihheight - $altezzamassima;
$ihheight1 = $ihheight - $ihheightprovvisorio;
$prendimolapercentualetolta2 = ($ihheightprovvisorio/$ihwidth)*100;
$ihwidthprovv =($ihwidth * $prendimolapercentualetolta2)/100;
$ihwidth1 = round($ihwidth - $ihwidthprovv);
}

}
else if($ihwidth &lt;= $larghezzamassima &amp;&amp; $ihheight &lt;= $altezzamassima) {
$ihwidth1 = $ihwidth;
$ihheight1 = $ihheight;
}
</code></pre>
<p dir="auto">Io vorrei solo ricreare l'immagine senza perdere il ratio..</p>
<p dir="auto">Avete idee?</p>
]]></description><link>https://dev.connect.gt/topic/157873/script-resize-image-mantenendo-proporzioni</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 18:53:25 GMT</lastBuildDate><atom:link href="https://dev.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:</p>
<pre><code class="language-php">//recupero altezza e larghezza

$imagesize = @getimagesize($nome_file_temporaneo);
$ihwidth= $imagesize[0];
$ihheight= $imagesize[1];

//IMPOSTO UN MASSIMALE PER LE IMMAGINI
$am = "150";
$lm = "150";

if($ihwidth &gt; $lm or $ihheight &gt; $am) {
$eliminarel = $ihwidth - $lm;
$eliminarea = $ihheight - $am;
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel*100)/$ihwidth);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea*100)/$ihheight);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
}
else {
$ihwidth1 = $ihwidth;
$ihheight1 = $ihheight;
}  

//se l'immagine sarà da ridimensionare, verrà ridimensionata grazie allo script che calcola le giuste variazioni

$thumb2 = imagecreatetruecolor($ihwidth1, $ihheight1);
imagecopyresized($thumb2, $source, 0, 0, 0, 0, $ihwidth1, $ihheight1, $ihwidth, $ihheight);
$anteprima2 = "nomefoto";
imagejpeg($thumb2, "percorso della foto".$anteprima2, 75);
</code></pre>
<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://dev.connect.gt/post/1025478</link><guid isPermaLink="true">https://dev.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[<blockquote>
<p dir="auto"><strong>Sovietiko</strong></p>
<p dir="auto">C'erano 2 errori, questo è perfetto:</p>
<pre><code class="language-php">//IMPOSTO UN MASSIMALE PER LE IMMAGINI
$am = "150";
$lm = "150";

if($ihwidth &gt; $lm or $ihheight &gt; $am) {
$eliminarel = $ihwidth - $lm;
$eliminarea = $ihheight - $am;
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel*100)/$ihwidth);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea*100)/$ihheight);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
}
else {
$ihwidth1 = $ihwidth;
$ihheight1 = $ihheight;
}
</code></pre>
</blockquote>
<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://dev.connect.gt/post/1025481</link><guid isPermaLink="true">https://dev.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://dev.connect.gt/post/1025488</link><guid isPermaLink="true">https://dev.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://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--wink" style="height:1.4em;width:auto;vertical-align:middle" title=";)" alt="😉" /></p>
]]></description><link>https://dev.connect.gt/post/1025476</link><guid isPermaLink="true">https://dev.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">Certo! Spero sarà utile a tutti! <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/1025477</link><guid isPermaLink="true">https://dev.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://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://dev.connect.gt/post/1025475</link><guid isPermaLink="true">https://dev.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>
<pre><code class="language-php">//IMPOSTO UN MASSIMALE PER LE IMMAGINI
$am = "150";
$lm = "150";

if($ihwidth &gt; $lm or $ihheight &gt; $am) {
$eliminarel = $ihwidth - $lm;
$eliminarea = $ihheight - $am;
if ($eliminarel &gt;= $eliminarea)  { $perc = round(($eliminarel*100)/$ihwidth);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
else if ($eliminarel &lt; $eliminarea) { $perc = round(($eliminarea*100)/$ihheight);
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
}
else {
$ihwidth1 = $ihwidth;
$ihheight1 = $ihheight;
}
</code></pre>
]]></description><link>https://dev.connect.gt/post/1025473</link><guid isPermaLink="true">https://dev.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>
<pre><code class="language-php">list($ihwidth,$ihheight) = explode('x',$grandezza);
//IMPOSTO UN MASSIMALE PER LE IMMAGINI
$am = "270";
$lm = "240";
if($ihwidth &gt; $lm or $ihheight &gt; $am) {
$eliminarel = $ihwidth - $lm;
$eliminarea = $ihheight - $am;
if (($elimnarel - $eliminarea) &gt; ($eliminarea - $eliminarel)) { $perc = ($eliminarel*100)/$ihwidth;
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
else if (($elimnarel - $eliminarea) &lt; ($eliminarea - $eliminarel)) { $perc = ($eliminarea*100)/$ihheight;
$ihw = round(($ihwidth/100)*$perc);
$ihwidth1 = $ihwidth-$ihw;
$ihh = round(($ihheight/100)*$perc);
$ihheight1 = $ihheight - $ihh;
}
}
else {
$ihwidth1 = $ihwidth;
$ihheight1 = $ihheight;
}
</code></pre>
<p dir="auto">Funziona alla perfezione dato che calcola le %.</p>
<p dir="auto">Saluti.</p>
]]></description><link>https://dev.connect.gt/post/1025474</link><guid isPermaLink="true">https://dev.connect.gt/post/1025474</guid><dc:creator><![CDATA[sovietiko]]></dc:creator><pubDate>Fri, 14 Oct 2011 07:42:03 GMT</pubDate></item></channel></rss>