Resize/crop/pad a picture to a fixed size

This solution is basically the same as Can Berk Güder’s, but after having spent some time writing and commenting, I felt like posting. This function creates a thumbnail that is exactly as big as the size you give it. The image is resized to best fit the size of the thumbnail. If it does not … Read more

How to crop a polygonal area from an image in a WinForm pictureBox? [closed]

You can make the List of Points into a Polygon, then into a GraphicsPath and then into a Region and after Graphics.Clip(Region) you can Graphics.DrawImage and are done..: using System.Drawing.Drawing2D; GraphicsPath gp = new GraphicsPath(); // a Graphicspath gp.AddPolygon(points.ToArray()); // with one Polygon Bitmap bmp1 = new Bitmap(555,555); // ..some new Bitmap // and some … Read more

How to crop the parsed image in android?

I assume you’ve already “got” the images down from the website and want to resize rather than crop? I.e. create thumbnails. If so, you can use the following: // load the origial BitMap (500 x 500 px) Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.android); int width = bitmapOrg.width(); int height = bitmapOrg.height(); int newWidth = 200; int … Read more

How to select and crop an image in android?

I have also faced this problem .You can try with this code. Its working fine for me private static final String TEMP_PHOTO_FILE = “temporary_holder.jpg”; Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType(“image/*”); photoPickerIntent.putExtra(“crop”, “true”); photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri()); photoPickerIntent.putExtra(“outputFormat”, Bitmap.CompressFormat.JPEG.toString()); startActivityForResult(photoPickerIntent, REQ_CODE_PICK_IMAGE); private Uri getTempUri() { return Uri.fromFile(getTempFile()); } private File getTempFile() { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File file … Read more

Cropping a PDF using Ghostscript 9.01

First, take note that the measurement unit for PDF is the same as for PostScript: it’s called a point [pt]. 72 points == 1 inch == 25.4 millimeters Assuming you have a page size of A4. Then the media dimensions are: 595 points width == 210 millimeters 842 points height == 297 millimeters Assuming you … Read more

Crop image in PHP

If you are trying to generate thumbnails, you must first resize the image using imagecopyresampled();. You must resize the image so that the size of the smaller side of the image is equal to the corresponding side of the thumb. For example, if your source image is 1280x800px and your thumb is 200x150px, you must … Read more

Android Crop Center of Bitmap

This can be achieved with: Bitmap.createBitmap(source, x, y, width, height) if (srcBmp.getWidth() >= srcBmp.getHeight()){ dstBmp = Bitmap.createBitmap( srcBmp, srcBmp.getWidth()/2 – srcBmp.getHeight()/2, 0, srcBmp.getHeight(), srcBmp.getHeight() ); }else{ dstBmp = Bitmap.createBitmap( srcBmp, 0, srcBmp.getHeight()/2 – srcBmp.getWidth()/2, srcBmp.getWidth(), srcBmp.getWidth() ); }