<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: resize code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 02:37:51 GMT</pubDate>
    <description>DZone Snippets: resize code</description>
    <item>
      <title>Simple Resize PIL Image with python</title>
      <link>http://snippets.dzone.com/posts/show/5779</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def resize(im,percent):&lt;br /&gt;    """ retaille suivant un pourcentage 'percent' """&lt;br /&gt;    w,h = im.size&lt;br /&gt;    return im.resize(((percent*w)/100,(percent*h)/100))&lt;br /&gt;&lt;br /&gt;def resize2(im,pixels):&lt;br /&gt;    """ retaille le cot&#233; le plus long en 'pixels' &lt;br /&gt;        (pour tenir dans une frame de pixels x pixels)&lt;br /&gt;    """&lt;br /&gt;    (wx,wy) = im.size&lt;br /&gt;    rx=1.0*wx/pixels&lt;br /&gt;    ry=1.0*wy/pixels&lt;br /&gt;    if rx&gt;ry:&lt;br /&gt;        rr=rx&lt;br /&gt;    else:&lt;br /&gt;        rr=ry&lt;br /&gt;&lt;br /&gt;    return im.resize((int(wx/rr), int(wy/rr)))&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 17 Jul 2008 09:48:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5779</guid>
      <author>manatlan (manatlan)</author>
    </item>
    <item>
      <title>Howto resize multiple pictures, graphics, images</title>
      <link>http://snippets.dzone.com/posts/show/5440</link>
      <description>&lt;code&gt;&lt;br /&gt;for k in $(ls *.jpg); do convert -resize 800 -quality 80 $k r800-$k; done&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 29 Apr 2008 16:41:33 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5440</guid>
      <author>flynets (Flynets is an italian student of computer science with passion for GNU/Linux and hacktivism.)</author>
    </item>
    <item>
      <title>Batch re-size a collection of images from the command line</title>
      <link>http://snippets.dzone.com/posts/show/5298</link>
      <description>&lt;code&gt;&lt;br /&gt;for img in $(ls *.png); do convert $img -resize 75% smaller-$img; done;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 01 Apr 2008 09:33:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5298</guid>
      <author>27stars (27stars)</author>
    </item>
    <item>
      <title>C#: Resize An Image While Maintaining Aspect Ratio and Maximum Height</title>
      <link>http://snippets.dzone.com/posts/show/4336</link>
      <description>// This allows us to resize the image. It prevents skewed images and &lt;br /&gt;// also vertically long images caused by trying to maintain the aspect &lt;br /&gt;// ratio on images who's height is larger than their width&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)&lt;br /&gt;{&lt;br /&gt;	System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);&lt;br /&gt;&lt;br /&gt;	// Prevent using images internal thumbnail&lt;br /&gt;	FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);&lt;br /&gt;	FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);&lt;br /&gt;&lt;br /&gt;	if (OnlyResizeIfWider)&lt;br /&gt;	{&lt;br /&gt;		if (FullsizeImage.Width &lt;= NewWidth)&lt;br /&gt;		{&lt;br /&gt;			NewWidth = FullsizeImage.Width;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;&lt;br /&gt;	if (NewHeight &gt; MaxHeight)&lt;br /&gt;	{&lt;br /&gt;		// Resize with height instead&lt;br /&gt;		NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;&lt;br /&gt;		NewHeight = MaxHeight;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;	// Clear handle to original file so that we can overwrite it if necessary&lt;br /&gt;	FullsizeImage.Dispose();&lt;br /&gt;&lt;br /&gt;	// Save resized picture&lt;br /&gt;	NewImage.Save(NewFile);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 19 Jul 2007 22:55:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4336</guid>
      <author>cornerblue (CornerBLUE, Inc.)</author>
    </item>
    <item>
      <title>Image/canvas bliting</title>
      <link>http://snippets.dzone.com/posts/show/926</link>
      <description>I can't remember how to call the blit method.&lt;br /&gt;So, here's just a personal reminder.&lt;br /&gt;(BTW, the pys60 doc has a wrong order between target and source)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;app.body = c = Canvas()&lt;br /&gt;w,h = 20,20&lt;br /&gt;im = Image.new(size=(w,h))&lt;br /&gt;&lt;br /&gt;# here's prototype&lt;br /&gt;# blit(im, source=(0,0,w,h), target=(0,0), mask=None, scale=0)&lt;br /&gt;# here are examples&lt;br /&gt;c.blit(im)  # put entire image on top-left&lt;br /&gt;c.blit(im, target=(70,70)) # put it about mid-screen&lt;br /&gt;c.blit(im, (0,0,w/2,h/2))  # put a quater image on top-left&lt;br /&gt;&lt;br /&gt;# double the image size and put it about mid-screen&lt;br /&gt;c.blit(im, target=(60,60,100,100), scale=1)&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;If scale is not specified and source &lt;&gt; target, the image&lt;br /&gt;will be clipped instead of resized.&lt;br /&gt;&lt;br /&gt;mask is a 1-bit image with the same size as image.&lt;br /&gt;&lt;code&gt;mask = Image.new((w,h),'1')&lt;/code&gt;&lt;br /&gt;Pixel on the image will be copied if the same pixel&lt;br /&gt;on the mask is 'white'.&lt;br /&gt;So we can use mask to make 'Sprite'.</description>
      <pubDate>Thu, 01 Dec 2005 20:57:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/926</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Readable, resizable font in stylesheet</title>
      <link>http://snippets.dzone.com/posts/show/786</link>
      <description>&lt;code&gt;&lt;br /&gt;body, td {font:90% Tahoma, [other fonts]}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Today I found an apps where its Thai font is ugly.&lt;br /&gt;I added this 90% Tahoma to its font style.&lt;br /&gt;Don't use pixel (px). It's unresizable (unless using FF).</description>
      <pubDate>Thu, 06 Oct 2005 00:52:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/786</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
    <item>
      <title>Drag and Drop image with javascript</title>
      <link>http://snippets.dzone.com/posts/show/512</link>
      <description>&lt;code&gt;&lt;br /&gt;&lt;body&gt;&lt;br /&gt;&lt;script src="http://www.walterzorn.com/scripts/wz_dragdrop.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;img name="name1" src="someImg.jpg" width=240 height=135&gt;&lt;br /&gt;&lt;br /&gt;&lt;script&gt;SET_DHTML("name1")&lt;/script&gt;&lt;br /&gt;&lt;/body&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;You can make the image resizable (using shift-drag) by&lt;br /&gt;&lt;code&gt;&lt;br /&gt;SET_DHTML("name1"+RESIZABLE) // any size&lt;br /&gt;SET_DHTML("name1"+SCALABLE) // keep aspect ratio&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;See more detail here&lt;br /&gt;http://www.walterzorn.com/dragdrop/dragdrop_e.htm</description>
      <pubDate>Wed, 27 Jul 2005 17:10:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/512</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
