<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Valentino Aluigi &#187; tech</title>
	<atom:link href="http://www.maverick.it/category/tech/feed" rel="self" type="application/rss+xml" />
	<link>http://www.maverick.it</link>
	<description>Progettista siti web</description>
	<lastBuildDate>Tue, 29 Sep 2009 15:27:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>it</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>More API for More Fields</title>
		<link>http://www.maverick.it/tech/more-fields-api</link>
		<comments>http://www.maverick.it/tech/more-fields-api#comments</comments>
		<pubDate>Fri, 11 Sep 2009 16:33:01 +0000</pubDate>
		<dc:creator>Valentino</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.maverick.it/?p=281</guid>
		<description><![CDATA[In a recent collaboration with Nicolò Volpato I used More Fields Worpdress plugin to implement a shopping cart.
More Fields is a lightweight plugin (compared to Flutter) that add custom fields and give the ability to create new type of contents. If you use it, you&#8217;ll find my plugin More Fields API very helpful.
I wrote this [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent collaboration with <a href="http://www.gnvpartners.com/web/">Nicolò Volpato</a> I used <a href="http://wordpress.org/extend/plugins/more-fields/">More Fields</a> Worpdress plugin to implement a shopping cart.</p>
<p>More Fields is a lightweight plugin (compared to <a href="http://flutter.freshout.us/">Flutter</a>) that add custom fields and give the ability to create new type of contents. If you use it, you&#8217;ll find my plugin <strong>More Fields API</strong> very helpful.</p>
<p>I wrote this one-file plugin to give <strong>a better interface for theme developers</strong>. It&#8217;s coded in object-oriented paradigm, and requires PHP 5. Just copy the file in the plugins folder and activate it. You are free to use this code as you like.</p>
<blockquote><p><a href="/files/more-fields-api.txt">Download More Fields API</a></p></blockquote>
<h2>Hide custom types from the Loop</h2>
<p>The single most useful function here is <strong>mfAPI::activate_filter()</strong>. Just call it on top of your functions.php and you&#8217;ll filter out all the custom types from the usual Worpress flow.</p>
<p>This is especially handy if you derived a custom type from posts. In my case I created a type called &#8220;product&#8221;. Without this trick, I had products popping out everywhere on the blog.</p>
<p>In case you used Wordpress <em>get_posts()</em> function you should replace it with <em>$wp_query->get_posts()</em> because get_posts is not filtered.</p>
<p>If you use <em>$wp_query->get_posts()</em> a lot, sometimes you&#8217;ll notice Wordpress may get crazy results. To fix this call <em>$wp_query->init()</em> before get_posts.</p>
<blockquote><p>Warning: if you call mfAPI:activate_filter() on top of your functions.php, don&#8217;t deactivate the plugin before removing this line of code</p></blockquote>
<h2>Get contents of a specified type</h2>
<p>The second most useful function is <strong>mfAPI::get_posts()</strong>. Use it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$products</span> <span style="color: #339933;">=</span> mfApi<span style="color: #339933;">::</span><span style="color: #004000;">get_posts</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$products</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
    <span style="color: #666666; font-style: italic;">/* do something with $product */</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This function has some awesome <strong>tricks</strong>. You&#8217;ll find every custom fields you added to this type as a property of the posts.<br />
In my case the product type has a box with only a custom field, <em>price</em>.<br />
So, I can print all the prices with this simple code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$products</span> <span style="color: #339933;">=</span> mfApi<span style="color: #339933;">::</span><span style="color: #004000;">get_posts</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$products</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">price</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Another trick is the <strong>automatic extraction of the first image</strong> in the post. Just set the fourth param to true and you can do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$products</span> <span style="color: #339933;">=</span> mfApi<span style="color: #339933;">::</span><span style="color: #004000;">get_posts</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$products</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$product</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_image</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you look at the other options, you&#8217;ll find you can easily use it to <strong>implement pagination</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">/*
     * Return an array of posts of the specified type, with custom fields
     *
     * @param string $type          custom field type
     * @param int $count            max number of elements (0 for all)
     * @param int $offset           start from this offset (user for pagination)
     * @param int $extract_image    define if we should automatically extract an image
     * @param string $where         optional mysql where
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$type</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$extract_image</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span></pre></div></div>

<h2>Other complex functions</h2>
<ul>
<li><strong>get_post()</strong> &#8211; get a single post (even inside the Loop) with all the benefits of get_posts()</li>
<li><strong>get_posts_by_tag()</strong> &#8211; filter custom content by type and tag</li>
<li><strong>get_similars()</strong> &#8211; return custom content sorted by tag similarity</li>
</ul>
<h2>Basic functions</h2>
<ul>
<li><strong>get_type()</strong> &#8211; retun the type of a content</li>
<li><strong>get_posts_count()</strong> &#8211; return the number of contents of a specified type (useful for pagination)</li>
<li><strong>get_custom_boxes()</strong> &#8211; return custom boxes for a specified type</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.maverick.it/tech/more-fields-api/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create thumbnails using Wordpress built-in functions</title>
		<link>http://www.maverick.it/tech/create-thumbnails-using-wordpress-built-in-functions</link>
		<comments>http://www.maverick.it/tech/create-thumbnails-using-wordpress-built-in-functions#comments</comments>
		<pubDate>Fri, 11 Sep 2009 14:30:04 +0000</pubDate>
		<dc:creator>Valentino</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.maverick.it/?p=258</guid>
		<description><![CDATA[I was pleased to discover that there&#8217;s a better way to create thumbnails in Wordpress than code it yourself, or use a third party library.
In fact, in wp-includes/media.php there&#8217;s a whole bunch of functions that Wordpress (since 2.5) uses to manipulate media files.
image_resize() is exactly what we need:

/**
 * Scale down an image to fit [...]]]></description>
			<content:encoded><![CDATA[<p>I was pleased to discover that there&#8217;s a better way to create thumbnails in Wordpress than code it yourself, or use a <a href="http://code.google.com/p/timthumb/">third party library</a>.</p>
<p>In fact, in <em>wp-includes/media.php</em> there&#8217;s a whole bunch of functions that Wordpress (since 2.5) uses to manipulate media files.</p>
<p><em>image_resize()</em> is exactly what we need:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Scale down an image to fit a particular size and save a new copy of the image.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> image_resize<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max_h</span><span style="color: #339933;">,</span> <span style="color: #000088;">$crop</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$suffix</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dest_path</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$jpeg_quality</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>You can use it like this to create a perfect 100&#215;60 thumbnail:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// resize the image</span>
<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> image_resize<span style="color: #009900;">&#40;</span><span style="color: #000088;">$img</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The tricky part is that, because Wordpress use this function in the admin, it needs some code that&#8217;s not available to themes by default.<br />
You can fix this by including <em>wp-admin/includes/image.php</em> on top of your <em>functions.php</em>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/// admin image API</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>ABSPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/wp-admin/includes/image.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>thumbnails.php</h2>
<p>To make thumbnail generation even easier, I coded some usefull functions you can grab.<br />
This functions work on images placed on posts and uploaded on <em>wp-content</em>.</p>
<p><a href="/files/thumbnails.txt">Download thumbnails.php</a></p>
<p><strong>the_thumb()</strong> is the easiest one. You can call it inside <a href="http://codex.wordpress.org/The_Loop">the Loop</a> to extract the first image in the content, resize it, and output an image tag. Of course, like all Wordpress functions, there&#8217;s the corresponding <strong>get_the_thumb()</strong>.</p>
<p><strong>generate_thumb()</strong> it&#8217;s a shortcut for image_resize(), with some addictions.</p>
<p>Finally, <strong>extract_image()</strong> return the url of the first image in an html string.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// extract the first image of the post</span>
<span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> extract_image<span style="color: #009900;">&#40;</span>get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.maverick.it/tech/create-thumbnails-using-wordpress-built-in-functions/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Drupal &#8211; seconda chance</title>
		<link>http://www.maverick.it/tech/drupal-seconda-chance</link>
		<comments>http://www.maverick.it/tech/drupal-seconda-chance#comments</comments>
		<pubDate>Mon, 20 Apr 2009 15:37:48 +0000</pubDate>
		<dc:creator>Valentino</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.maverick.it/?p=160</guid>
		<description><![CDATA[Ad ottobre 2007 ho pubblicato il mio primo e unico sito basato su Drupal (per la cronaca, è il sito della principale associazione nazionale di improvvisazione teatrale).
Dopo mesi di sviluppo intenso e problematico, dentro e fuori,  ho deciso che non avrei mai più adottato quel CMS, e ho invece cominciato una lunga e felice luna [...]]]></description>
			<content:encoded><![CDATA[<p>Ad ottobre 2007 ho pubblicato il mio primo e unico sito basato su Drupal (per la cronaca, è il sito della principale <a href="http://www.improteatro.it">associazione nazionale di improvvisazione teatrale</a>).</p>
<p>Dopo mesi di sviluppo intenso e problematico, dentro e fuori,  ho deciso che non avrei mai più adottato quel CMS, e ho invece cominciato una lunga e felice luna di miele con Wordpress.</p>
<p>Ma da allora è passato più di un anno, è uscita la nuova verisone 6 di Drupal, ora conosco molto meglio il CMS di quando ho cominciato, e insomma ho pensato che valeva la pena ridargli <strong>un&#8217;altra occasione</strong>.</p>
<p>Purtroppo mi è bastato testare una nuova installazione per accorgermi che mentre <strong>Wordpress ha fatto passi da giganti</strong>, Drupal è rimasto pressochè identico.</p>
<p>Per le mie esigenze Drupal ha almeno tre problemi importanti:</p>
<ul>
<li><strong>Non è user-friendly</strong>: dal momento che è una piattaforma per la pubblicazione di contenuti, è una grossa mancanza. I miei clienti non sono programmatori, e hanno diritto ad una interfaccia semplice e usabile.</li>
<li><strong>E&#8217; troppo macchinoso:</strong> spesso è più facile programmarsi le features aggiuntive da soli piuttosto che usare gli strumenti inclusi</li>
<li><strong>E&#8217; monolitico</strong>: nonostante la struttura modulare, non è affatto flessibile, e ci si ritrova a perdere più tempo a sfrondare il codice inutile che a sviluppare</li>
</ul>
<p>Insomma, dopo aver scaricato e installato il core, la traduzione (lacunosa) italiana, una quindicina di moduli base per aver qualcosa di simile a Wordpress, ho gettato di nuovo la spugna.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maverick.it/tech/drupal-seconda-chance/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Perchè AJAX piuttosto che Flash</title>
		<link>http://www.maverick.it/tech/perche-ajax-piuttosto-che-flash</link>
		<comments>http://www.maverick.it/tech/perche-ajax-piuttosto-che-flash#comments</comments>
		<pubDate>Tue, 07 Apr 2009 08:28:30 +0000</pubDate>
		<dc:creator>Valentino</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.maverick.it/?p=140</guid>
		<description><![CDATA[Riprendendo una discussione nata nei commenti di qualche articolo fa vorrei puntualizzare alcune differenze importanti tra due tecnologie: Ajax e Flash.
Premetto che l&#8217;ambito di interesse è lo sviluppo di RIA, cioè di applicazioni internet con potenzialità simili a quelle desktop.
Fatte queste premesse, se analizziamo la scena globale ci accorgiamo che ad eccezione delle RIA che [...]]]></description>
			<content:encoded><![CDATA[<p>Riprendendo una discussione nata nei commenti di qualche articolo fa vorrei puntualizzare alcune differenze importanti tra due tecnologie: Ajax e Flash.</p>
<p>Premetto che l&#8217;ambito di interesse è lo sviluppo di <a href="http://it.wikipedia.org/wiki/Rich_Internet_application">RIA</a>, cioè di <strong>applicazioni internet</strong> con potenzialità simili a quelle desktop.</p>
<p>Fatte queste premesse, se analizziamo la scena globale ci accorgiamo che ad eccezione delle RIA che si occupano di grafica (come <a href="http://aviary.com/home">Aviary</a> o <a href="https://www.photoshop.com/index.html?wf=mobile&amp;promoid=DTELB">Photoshop Express</a>), <strong>la maggior parte delle applicazioni web sono sviluppate in AJAX</strong>.</p>
<p>Ecco alcuni esempi importanti: tutti gli applicativi Google (<a href="http://docs.google.com/">Google Documenti</a>, GMail, Google Calendar&#8230;), la suite completa per l&#8217;ufficio <a href="http://www.zoho.com/">Zoho</a>, ma anche i pannelli di amministrazione dei principali CMS (come la nuova interfaccia amministrativa di <a href="http://wordpress.org/">Wordpress</a>, dalla quale sto scrivendo), senza contare i Social Network come Facebook che per la loro complessità assomigliano sempre più a vere e proprie RIA.</p>
<p>Inoltre, questo non riguarda solo i &#8220;<em>big player</em>&#8220;: la quasi totalità delle piccole web-applications 2.0, scritte in PHP o RubyOnRails, continuano a fare uso estensivo di AJAX.</p>
<p> </p>
<h2>Perchè AJAX</h2>
<p>E allora, quali sono questi vantaggi e quali svantaggi nel costruire un&#8217;applicazione interamente in Flash?</p>
<ul>
<li>Anzitutto, Flash è spaesante per l&#8217;utente. Il tasto destro non funziona come ci si aspetta, <strong>molte </strong><strong>convenzioni che favoriscono l&#8217;usabilità non sono rispettate</strong>.</li>
<li>Fare una cosa semplice come <strong>selezionare e copiare del testo</strong> può diventare complicato o impossibile.</li>
<li>Le abitudini sulla navigazione sono disattese: spesso le applicazioni Flash non hanno pagine o diversi indirizzi URL.</li>
<li>Molte funzionalità dei browser vengono annullate: Flash di fatto nega al browser e ai suoi plugin di entrare nell&#8217;applicazione e personalizzarne la visualizzazione.</li>
<li>Ad esempio: impostare la <strong>dimesione preferita del testo</strong> non ho effetti su Flash, i web accellerator e le web slices di Internet Explorer 8 non funzionano, nemmeno i plugin di Firefox per filtrare la pubblicità, e l&#8217;elenco potrebbe essere veramente infinito.</li>
<li>Per non parlare della <strong>stampa</strong>, che se già normalmente da spesso risultati inattesi, con Flash non viene nemmeno presa in considerazione.</li>
<li>Ultimo ma non ultimo, Flash ha maggiori problemi di accessibilità, sia per chi usa screen reader sia per dispositivi alternativi o mobile.</li>
</ul>
<h2></h2>
<h2>Salvare il bambino</h2>
<p>Non buttiamo però il bambino con l&#8217;acqua sporca.</p>
<p>Se è vero che usare Flash per l&#8217;intera interfaccia ha i suoi svantaggi, anche nell&#8217;ambito delle RIA Flash continua ad essere un&#8217;ottima scelta per:</p>
<ul>
<li>Sfruttare potenzialità avanzate come l&#8217;upload multiplo di file (vedi ad esempio la libreria <a href="http://swfupload.org/">SWFUpload</a>: Flash c&#8217;è, ma non si vede) o il salvataggio dati nel browser (vedi <a href="http://ajaxian.com/archives/dojostorage-offline-access-and-permanent-client-side-storage">dojo.storage</a>)</li>
<li>Animazioni grafiche circoscritte (anche in questo ambito AJAX offre alternative interessanti, ma Flash resta il top)</li>
<li>Grafici interattivi animati (vedi <a href="http://www.google.com/analytics/it-IT/">Google Analytics</a>)</li>
</ul>
<p>Che ne pensate?</p>
<p>Ho tralasciato qualche punto importante?</p>
<p>I commenti sono sempre ben accetti.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maverick.it/tech/perche-ajax-piuttosto-che-flash/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Manipolazione immagini in PHP5</title>
		<link>http://www.maverick.it/tech/manipolazione-immagini-in-php5</link>
		<comments>http://www.maverick.it/tech/manipolazione-immagini-in-php5#comments</comments>
		<pubDate>Sat, 07 Mar 2009 13:49:16 +0000</pubDate>
		<dc:creator>Valentino</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[immagini]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[risorse]]></category>
		<category><![CDATA[sviluppo]]></category>

		<guid isPermaLink="false">http://www.maverick.it/?p=127</guid>
		<description><![CDATA[Se siete in cerca di una soluzione per la manipolazione delle immagini in PHP suggerisco WideImage.
E&#8217; una libreria PHP 5 che semplifica l&#8217;elaborazione e funziona da wrapper per le varie GD, GD2 e ImageMagick.
Oltre che essere estremamente potente è anche facile da utilizzare. Ad esempio:

$img = wiImage::load&#40;'image.png'&#41;;
$img-&#62;resize&#40;200, 500&#41;-&#62;crop&#40;10, 10, 80, 80&#41;-&#62;asGrayscale&#40;&#41;-&#62;saveToFile&#40;'new.png'&#41;;

Con due sole righe di codice [...]]]></description>
			<content:encoded><![CDATA[<p>Se siete in cerca di una soluzione per la manipolazione delle immagini in PHP suggerisco <a href="http://wideimage.sourceforge.net/wiki/MainPage">WideImage</a>.</p>
<p>E&#8217; una libreria PHP 5 che semplifica l&#8217;elaborazione e funziona da wrapper per le varie <em>GD</em>, <em>GD2 </em>e <em>ImageMagick</em>.</p>
<p>Oltre che essere <strong>estremamente potente</strong> è anche facile da utilizzare. Ad esempio:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$img</span> <span style="color: #339933;">=</span> wiImage<span style="color: #339933;">::</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'image.png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$img</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">crop</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">80</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">asGrayscale</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveToFile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'new.png'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Con due sole righe di codice apriamo un immagine, la ridimensioniamo, la ritagliamo, convertiamo in scala di grigi e salviamo in un nuovo file.</p>
<p>Mi è tornata utile all&#8217;interno di un progetto che sto sviluppando nel framework <a href="http://codeigniter.com/">CodeIgniter</a>.</p>
<p>Se conoscete il framework saprete che dispone già di una libreria per la gestione delle immagini.</p>
<p>Purtroppo, diversamente dal resto del codice, è scomoda da utlizzare, poco versatile e abbastanza irrazionale.</p>
<p>Se invece cercate una soluzione più immediata (adatta ai designer) vi suggerisco <a href="http://code.google.com/p/timthumb/">TimThumb</a>.</p>
<p>E&#8217; l&#8217;ideale per creare <strong>anteprime di immagini al volo</strong>, ad esempio dentro un tema per Wordpress.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maverick.it/tech/manipolazione-immagini-in-php5/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
