Take the 2-minute tour ×

Hey all i am looking for some asp.net code that mimics this PHP class here

Php Imagick

I need the code to be able to do as it does here:

$image = new Imagick('image.jpg');

// aspect ratio is maintained
$image->thumbnailImage(100, 0);

echo $image;

Notice where it says If 0 is provided as a width or height parameter, aspect ratio is maintained

I am unable to find any .net code currently that allows for something like above. I've seen plenty that allow both width and height to be specified but not just one. This PHP class mimics Photoshop re-size the best.

So therefore, an example would be:

$image = new Imagick('image.jpg'); //WHERE Width = 3216 & Height = 2064
$image->thumbnailImage(1024, 0); //WHERE Width = 1024    
echo $image;

The size of that image would turn out to be

width = 1024

height = 657

As it would do in Photoshop.


share|improve this question
Are you asking how to load and resize an image in .NET? Or are you asking for the math to find the 2nd dimension when you only have 1 and an aspect ratio? Or both? –  Cory Nelson Feb 7 '13 at 17:42
@CoryNelson I am looking to do both. I want it to know what it needs to use if i give it either the width or height. –  StealthRT Feb 7 '13 at 21:14

2 Answers 2

  1. Why don't you try using an IF condition to check for the 0 maintain?
  2. I like to do stuff like this in jscript/css, its a lot more tailored, even if I have to hook in by ID as you're generating images. (you can set up a naming scheme like image[1])
  3. Run your php class in .NET : http://www.infoq.com/articles/Phalanger .
share|improve this answer
1) Thats not what i asked... 2) JS does not have any graphics ability to make it look nice (ie no sharp lines, compressions, etc). 3) Again, not helpful since i do not want to run any PHP for a .net page... –  StealthRT Feb 7 '13 at 21:15

I wrote the ImageResizer library for this purpose, as there aren't any other server-safe image resizing libraries for .NET.

For optimal performance, use the included URL API instead of creating your own handler:


<img src="image.jpg?width=100" />


<img src="myinsecurehandler.ashx?file=image.jpg&width=100" />
share|improve this answer

Your Answer


