Håller på och tillverkar ett skript för att resizea och cropa bilder. Dock har jag mött på ett stort problem...
Bilderna i helt usel kvalitet! Då jag inte har någon anledning att spara bandbredd vill jag ha bra kvalitet på de resizeade bilderna.´
Kod:
public static void makeThumbnail(string orginal, string thumbnail, int maxW, int maxH)
*{
*
* System.Drawing.Image img;
* System.Drawing.Image thumb;
* int w;
* int h;
* img = System.Drawing.Image.FromFile(orginal);
* w = img.Width;
* h = img.Height;
* if (w > maxW)
* {
* *h = maxW * h / w;
* *w = maxW;
* }
* thumb = img.GetThumbnailImage(w, h, null, System.IntPtr.Zero);
* if (thumb.Height > maxH)
* {
* *System.Drawing.Bitmap btmImage = new Bitmap(thumb);
* *Rectangle recCrop = new Rectangle(0, 0, maxW, maxH);
* *Bitmap btmCrop = new Bitmap(recCrop.Width, recCrop.Height, btmImage.PixelFormat);
* *Graphics gphCrop = Graphics.FromImage(btmCrop);
* *Rectangle recDest = new Rectangle(0, 0, maxW, maxH);
* *gphCrop.DrawImage(btmImage, recDest, recCrop.X, recCrop.Y, recCrop.Width, recCrop.Height, GraphicsUnit.Pixel);
* *btmCrop.Save(thumbnail);
* }
* else
* {
* *thumb.Save(thumbnail);
* }
*}
Hur ska jag göra för att bildkvaliteten ska bli bättre?
Bifogar bild på hur det ser ut efter resize med skriptet, respektive i Photoshop.