Example usage for android.media ExifInterface ORIENTATION_ROTATE_90

List of usage examples for android.media ExifInterface ORIENTATION_ROTATE_90

Introduction

In this page you can find the example usage for android.media ExifInterface ORIENTATION_ROTATE_90.

Prototype

int ORIENTATION_ROTATE_90

To view the source code for android.media ExifInterface ORIENTATION_ROTATE_90.

Click Source Link

Usage

From source file:com.annanovas.bestprice.DashBoardEditActivity.java

private Bitmap imageProcess(Bitmap imageBitmap) {
    int width = imageBitmap.getWidth();
    int height = imageBitmap.getHeight();
    int newWidth = 1000;
    int newHeight = 1000;
    if (width > 1000) {
        double x = (double) width / 1000d;
        newHeight = (int) (height / x);
        newWidth = 1000;//  w  w w.  j  a  v  a 2  s . c  om
    } else if (height > 1000) {
        double x = (double) height / 1000d;
        newWidth = (int) (width / x);
        newHeight = 1000;
    }
    // calculate the scale - in this case = 0.4f
    ExifInterface exif = null;
    int rotationAngle = 0;
    try {
        exif = new ExifInterface(imageUri);
        String orientString = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
        // showLog("orientString:" + orientString + " DateTime:" + exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH));
        int orientation = orientString != null ? Integer.parseInt(orientString)
                : ExifInterface.ORIENTATION_NORMAL;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_90)
            rotationAngle = 90;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_180)
            rotationAngle = 180;
        if (orientation == ExifInterface.ORIENTATION_ROTATE_270)
            rotationAngle = 270;
        //  showLog("Rotation Angle:" + rotationAngle);
    } catch (IOException e) {
        // showLog("ExifInterface Failed!");
        e.printStackTrace();
    }
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    matrix.postRotate(rotationAngle);
    return Bitmap.createBitmap(imageBitmap, 0, 0, width, height, matrix, true);
}

From source file:com.almalence.opencam.SavingService.java

protected void addTimestamp(File file, int exif_orientation) {
    try {/*www. j  a  v  a 2 s  .  c  o  m*/
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

        int dateFormat = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampDate, "0"));
        boolean abbreviation = prefs.getBoolean(ApplicationScreen.sTimestampAbbreviation, false);
        int saveGeo = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampGeo, "0"));
        int timeFormat = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampTime, "0"));
        int separator = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampSeparator, "0"));
        String customText = prefs.getString(ApplicationScreen.sTimestampCustomText, "");
        int color = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampColor, "1"));
        int fontSizeC = Integer.parseInt(prefs.getString(ApplicationScreen.sTimestampFontSize, "80"));

        String formattedCurrentDate = "";
        if (dateFormat == 0 && timeFormat == 0 && customText.equals("") && saveGeo == 0)
            return;

        String geoText = "";
        // show geo data on time stamp
        if (saveGeo != 0) {
            Location l = MLocation.getLocation(getApplicationContext());

            if (l != null) {
                if (saveGeo == 2) {
                    Geocoder geocoder = new Geocoder(MainScreen.getMainContext(), Locale.getDefault());
                    List<Address> list = geocoder.getFromLocation(l.getLatitude(), l.getLongitude(), 1);
                    if (!list.isEmpty()) {
                        String country = list.get(0).getCountryName();
                        String locality = list.get(0).getLocality();
                        String adminArea = list.get(0).getSubAdminArea();// city
                        // localized
                        String street = list.get(0).getThoroughfare();// street
                        // localized
                        String address = list.get(0).getAddressLine(0);

                        // replace street and city with localized name
                        if (street != null)
                            address = street;
                        if (adminArea != null)
                            locality = adminArea;

                        geoText = (country != null ? country : "") + (locality != null ? (", " + locality) : "")
                                + (address != null ? (", \n" + address) : "");

                        if (geoText.equals(""))
                            geoText = "lat:" + l.getLatitude() + "\nlng:" + l.getLongitude();
                    }
                } else
                    geoText = "lat:" + l.getLatitude() + "\nlng:" + l.getLongitude();
            }
        }

        String dateFormatString = "";
        String timeFormatString = "";
        String separatorString = ".";
        String monthString = abbreviation ? "MMMM" : "MM";

        switch (separator) {
        case 0:
            separatorString = "/";
            break;
        case 1:
            separatorString = ".";
            break;
        case 2:
            separatorString = "-";
            break;
        case 3:
            separatorString = " ";
            break;
        default:
            separatorString = " ";
        }

        switch (dateFormat) {
        case 1:
            dateFormatString = "yyyy" + separatorString + monthString + separatorString + "dd";
            break;
        case 2:
            dateFormatString = "dd" + separatorString + monthString + separatorString + "yyyy";
            break;
        case 3:
            dateFormatString = monthString + separatorString + "dd" + separatorString + "yyyy";
            break;
        default:
        }

        switch (timeFormat) {
        case 1:
            timeFormatString = " hh:mm:ss a";
            break;
        case 2:
            timeFormatString = " HH:mm:ss";
            break;
        default:
        }

        Date currentDate = Calendar.getInstance().getTime();
        java.text.SimpleDateFormat simpleDateFormat = new java.text.SimpleDateFormat(
                dateFormatString + timeFormatString);
        formattedCurrentDate = simpleDateFormat.format(currentDate);

        formattedCurrentDate += (customText.isEmpty() ? "" : ("\n" + customText))
                + (geoText.isEmpty() ? "" : ("\n" + geoText));

        if (formattedCurrentDate.equals(""))
            return;

        Bitmap sourceBitmap;
        Bitmap bitmap;

        int rotation = 0;
        Matrix matrix = new Matrix();
        if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_90) {
            rotation = 90;
        } else if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_180) {
            rotation = 180;
        } else if (exif_orientation == ExifInterface.ORIENTATION_ROTATE_270) {
            rotation = 270;
        }
        matrix.postRotate(rotation);

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inMutable = true;

        sourceBitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
        bitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(),
                matrix, false);

        sourceBitmap.recycle();

        int width = bitmap.getWidth();
        int height = bitmap.getHeight();

        Paint p = new Paint();

        Canvas canvas = new Canvas(bitmap);

        final float scale = getResources().getDisplayMetrics().density;

        p.setColor(Color.WHITE);
        switch (color) {
        case 0:
            color = Color.BLACK;
            p.setColor(Color.BLACK);
            break;
        case 1:
            color = Color.WHITE;
            p.setColor(Color.WHITE);
            break;
        case 2:
            color = Color.YELLOW;
            p.setColor(Color.YELLOW);
            break;

        }

        if (width > height) {
            p.setTextSize(height / fontSizeC * scale + 0.5f); // convert dps
            // to pixels
        } else {
            p.setTextSize(width / fontSizeC * scale + 0.5f); // convert dps
            // to pixels
        }
        p.setTextAlign(Align.RIGHT);
        drawTextWithBackground(canvas, p, formattedCurrentDate, color, Color.BLACK, width, height);

        Matrix matrix2 = new Matrix();
        matrix2.postRotate(360 - rotation);
        sourceBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix2, false);

        bitmap.recycle();

        FileOutputStream outStream;
        outStream = new FileOutputStream(file);
        sourceBitmap.compress(Bitmap.CompressFormat.JPEG, jpegQuality, outStream);
        sourceBitmap.recycle();
        outStream.flush();
        outStream.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
    }
}

From source file:com.almalence.opencam.PluginManagerBase.java

public static int saveExifToInput(File file, int displayOrientation, boolean cameraMirrored, boolean saveGeo) {
    try {/*from  ww  w. jav a 2s .co m*/
        ExifInterface ei = new ExifInterface(file.getAbsolutePath());
        int exif_orientation = ExifInterface.ORIENTATION_NORMAL;
        switch (displayOrientation) {
        default:
        case 0:
            exif_orientation = ExifInterface.ORIENTATION_NORMAL;
            break;
        case 90:
            if (cameraMirrored) {
                displayOrientation = 270;
                exif_orientation = ExifInterface.ORIENTATION_ROTATE_270;
            } else {
                exif_orientation = ExifInterface.ORIENTATION_ROTATE_90;
            }
            break;
        case 180:
            exif_orientation = ExifInterface.ORIENTATION_ROTATE_180;
            break;
        case 270:
            if (cameraMirrored) {
                displayOrientation = 90;
                exif_orientation = ExifInterface.ORIENTATION_ROTATE_90;
            } else {
                exif_orientation = ExifInterface.ORIENTATION_ROTATE_270;
            }
            break;
        }
        ei.setAttribute(ExifInterface.TAG_ORIENTATION, "" + exif_orientation);

        if (saveGeo) {
            Location l = MLocation.getLocation(ApplicationScreen.getMainContext());

            if (l != null) {
                ei.setAttribute(ExifInterface.TAG_GPS_LATITUDE, GPSTagsConverter.convert(l.getLatitude()));
                ei.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF,
                        GPSTagsConverter.latitudeRef(l.getLatitude()));
                ei.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, GPSTagsConverter.convert(l.getLongitude()));
                ei.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF,
                        GPSTagsConverter.longitudeRef(l.getLongitude()));

            }
        }

        ei.saveAttributes();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return displayOrientation;
}

From source file:openscience.crowdsource.video.experiments.MainActivity.java

/**
 * Rotate an image if required.//www. j a  va  2 s  .c om
 *
 * @param selectedImagePath Image URI
 * @return The resulted Bitmap after manipulation
 */
private static int getImageDegree(String selectedImagePath) {

    ExifInterface ei = null;
    try {
        ei = new ExifInterface(selectedImagePath);
    } catch (IOException e) {
        AppLogger.logMessage("Error image could not be rotated " + e.getLocalizedMessage());
    }
    int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

    switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_90:
        return 90;
    case ExifInterface.ORIENTATION_ROTATE_180:
        return 180;
    case ExifInterface.ORIENTATION_ROTATE_270:
        return 270;
    default:
        return 0;
    }
}

From source file:com.almalence.opencam.SavingService.java

@TargetApi(21)
private void saveDNGPicture(int frameNum, long sessionID, OutputStream os, int width, int height,
        int orientation, boolean cameraMirrored) {
    DngCreator creator = new DngCreator(CameraController.getCameraCharacteristics(),
            PluginManager.getInstance().getFromRAWCaptureResults("captureResult" + frameNum + sessionID));
    byte[] frame = SwapHeap.SwapFromHeap(
            Integer.parseInt(getFromSharedMem("resultframe" + frameNum + Long.toString(sessionID))),
            Integer.parseInt(getFromSharedMem("resultframelen" + frameNum + Long.toString(sessionID))));

    ByteBuffer buff = ByteBuffer.allocateDirect(frame.length);
    buff.put(frame);//  w  w w .java 2s  .  c  o  m

    int exif_orientation = ExifInterface.ORIENTATION_NORMAL;
    switch ((orientation + 360) % 360) {
    default:
    case 0:
        exif_orientation = ExifInterface.ORIENTATION_NORMAL;
        break;
    case 90:
        exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_270
                : ExifInterface.ORIENTATION_ROTATE_90;
        break;
    case 180:
        exif_orientation = ExifInterface.ORIENTATION_ROTATE_180;
        break;
    case 270:
        exif_orientation = cameraMirrored ? ExifInterface.ORIENTATION_ROTATE_90
                : ExifInterface.ORIENTATION_ROTATE_270;
        break;
    }

    try {
        creator.setOrientation(exif_orientation);
        creator.writeByteBuffer(os, new Size(width, height), buff, 0);
    } catch (IOException e) {
        creator.close();
        e.printStackTrace();
        Log.e("Open Camera", "saveDNGPicture error: " + e.getMessage());
    }

    creator.close();
}

From source file:me.ccrama.redditslide.Views.SubsamplingScaleImageView.java

/**
 * Helper method for load tasks. Examines the EXIF info on the image file to determine the orientation.
 * This will only work for external files, not assets, resources or other URIs.
 *//*from   ww w  .j  a  va  2s.c o m*/
private int getExifOrientation(String sourceUri) {
    int exifOrientation = ORIENTATION_0;
    if (sourceUri.startsWith(ContentResolver.SCHEME_CONTENT)) {
        try {
            final String[] columns = { MediaStore.Images.Media.ORIENTATION };
            final Cursor cursor = getContext().getContentResolver().query(Uri.parse(sourceUri), columns, null,
                    null, null);
            if (cursor != null) {
                if (cursor.moveToFirst()) {
                    int orientation = cursor.getInt(0);
                    if (VALID_ORIENTATIONS.contains(orientation) && orientation != ORIENTATION_USE_EXIF) {
                        exifOrientation = orientation;
                    } else {
                        Log.w(TAG, "Unsupported orientation: " + orientation);
                    }
                }
                cursor.close();
            }
        } catch (Exception e) {
            Log.w(TAG, "Could not get orientation of image from media store");
        }
    } else if (sourceUri.startsWith(ImageSource.FILE_SCHEME)
            && !sourceUri.startsWith(ImageSource.ASSET_SCHEME)) {
        try {
            ExifInterface exifInterface = new ExifInterface(
                    sourceUri.substring(ImageSource.FILE_SCHEME.length() - 1));
            int orientationAttr = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_NORMAL);
            if (orientationAttr == ExifInterface.ORIENTATION_NORMAL
                    || orientationAttr == ExifInterface.ORIENTATION_UNDEFINED) {
                exifOrientation = ORIENTATION_0;
            } else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_90) {
                exifOrientation = ORIENTATION_90;
            } else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_180) {
                exifOrientation = ORIENTATION_180;
            } else if (orientationAttr == ExifInterface.ORIENTATION_ROTATE_270) {
                exifOrientation = ORIENTATION_270;
            } else {
                Log.w(TAG, "Unsupported EXIF orientation: " + orientationAttr);
            }
        } catch (Exception e) {
            Log.w(TAG, "Could not get EXIF orientation of image");
        }
    }
    return exifOrientation;
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object createImage(String path) throws IOException {
    int IMAGE_MAX_SIZE = getDisplayHeight();
    if (exists(path)) {
        Bitmap b = null;//from ww  w  . j a va 2  s. c o m
        try {
            //Decode image size
            BitmapFactory.Options o = new BitmapFactory.Options();
            o.inJustDecodeBounds = true;
            o.inPreferredConfig = Bitmap.Config.ARGB_8888;

            InputStream fis = createFileInputStream(path);
            BitmapFactory.decodeStream(fis, null, o);
            fis.close();

            int scale = 1;
            if (o.outHeight > IMAGE_MAX_SIZE || o.outWidth > IMAGE_MAX_SIZE) {
                scale = (int) Math.pow(2, (int) Math.round(
                        Math.log(IMAGE_MAX_SIZE / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5)));
            }

            //Decode with inSampleSize
            BitmapFactory.Options o2 = new BitmapFactory.Options();
            o2.inPreferredConfig = Bitmap.Config.ARGB_8888;

            if (sampleSizeOverride != -1) {
                o2.inSampleSize = sampleSizeOverride;
            } else {
                String sampleSize = Display.getInstance().getProperty("android.sampleSize", null);
                if (sampleSize != null) {
                    o2.inSampleSize = Integer.parseInt(sampleSize);
                } else {
                    o2.inSampleSize = scale;
                }
            }
            o2.inPurgeable = true;
            o2.inInputShareable = true;
            fis = createFileInputStream(path);
            b = BitmapFactory.decodeStream(fis, null, o2);
            fis.close();

            //fix rotation
            ExifInterface exif = new ExifInterface(path);
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_NORMAL);

            int angle = 0;
            switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                angle = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                angle = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                angle = 270;
                break;
            }

            if (sampleSizeOverride < 0 && angle != 0) {
                Matrix mat = new Matrix();
                mat.postRotate(angle);
                Bitmap correctBmp = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), mat, true);
                b.recycle();
                b = correctBmp;
            }
        } catch (IOException e) {
        }
        return b;
    } else {
        InputStream in = this.getResourceAsStream(getClass(), path);
        if (in == null) {
            throw new IOException("Resource not found. " + path);
        }
        try {
            return this.createImage(in);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ignored) {
                    ;
                }
            }
        }
    }
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Corrects the orientation of a Bitmap. Orientation, depending of the device
 * , is not correctly set in the EXIF data of the taken image when it is saved
 * into disk./*from   ww  w . j  a v a 2s .  co m*/
 * 
 * Explanation:
 *    Camera orientation is not working ok (as is when capturing an image) because 
 *  OEMs do not adhere to the standard. So, each company does this following their 
 *  own way.
 * 
 * @param imagePath   path to the file
 * @return
 */
public static Bitmap media_correctImageOrientation(String imagePath) {
    Bitmap res = null;

    try {
        File f = new File(imagePath);
        ExifInterface exif = new ExifInterface(f.getPath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

        int angle = 0;

        if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
            angle = 90;
        } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
            angle = 180;
        } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
            angle = 270;
        }

        Matrix mat = new Matrix();
        mat.postRotate(angle);
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 2;

        Bitmap bmp = BitmapFactory.decodeStream(new FileInputStream(f), null, options);
        res = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mat, true);

    } catch (OutOfMemoryError e) {
        if (LOG_ENABLE)
            Log.e(TAG, "media_correctImageOrientation() [OutOfMemory!]: " + e.getMessage(), e);
    } catch (Exception e) {
        if (LOG_ENABLE)
            Log.e(TAG, "media_correctImageOrientation(): " + e.getMessage(), e);
    } catch (Throwable e) {
        if (LOG_ENABLE)
            Log.e(TAG, "media_correctImageOrientation(): " + e.getMessage(), e);
    }

    return res;
}

From source file:com.irccloud.android.activity.MainActivity.java

private Uri resize(Uri in) {
    Uri out = null;//from w  w  w .ja  v a  2  s.c  o  m
    try {
        int MAX_IMAGE_SIZE = Integer
                .parseInt(PreferenceManager.getDefaultSharedPreferences(this).getString("photo_size", "1024"));
        File imageDir = new File(Environment.getExternalStorageDirectory(), "IRCCloud");
        imageDir.mkdirs();
        new File(imageDir, ".nomedia").createNewFile();

        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(IRCCloudApplication.getInstance().getApplicationContext()
                .getContentResolver().openInputStream(in), null, o);
        int scale = 1;

        if (o.outWidth < MAX_IMAGE_SIZE && o.outHeight < MAX_IMAGE_SIZE)
            return in;

        if (o.outWidth > o.outHeight) {
            if (o.outWidth > MAX_IMAGE_SIZE)
                scale = o.outWidth / MAX_IMAGE_SIZE;
        } else {
            if (o.outHeight > MAX_IMAGE_SIZE)
                scale = o.outHeight / MAX_IMAGE_SIZE;
        }

        o = new BitmapFactory.Options();
        o.inSampleSize = scale;
        Bitmap bmp = BitmapFactory.decodeStream(IRCCloudApplication.getInstance().getApplicationContext()
                .getContentResolver().openInputStream(in), null, o);

        //ExifInterface can only work on local files, so make a temporary copy on the SD card
        out = Uri.fromFile(File.createTempFile("irccloudcapture-original", ".jpg", imageDir));
        InputStream is = IRCCloudApplication.getInstance().getApplicationContext().getContentResolver()
                .openInputStream(in);
        OutputStream os = IRCCloudApplication.getInstance().getApplicationContext().getContentResolver()
                .openOutputStream(out);
        byte[] buffer = new byte[8192];
        int len;
        while ((len = is.read(buffer)) != -1) {
            os.write(buffer, 0, len);
        }
        is.close();
        os.close();

        ExifInterface exif = new ExifInterface(out.getPath());
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
        new File(new URI(out.toString())).delete();

        out = Uri.fromFile(File.createTempFile("irccloudcapture-resized", ".jpg", imageDir));
        if (orientation > 1) {
            Matrix matrix = new Matrix();
            switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                matrix.postRotate(90);
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                matrix.postRotate(180);
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                matrix.postRotate(270);
                break;
            }
            try {
                Bitmap oldbmp = bmp;
                bmp = Bitmap.createBitmap(oldbmp, 0, 0, oldbmp.getWidth(), oldbmp.getHeight(), matrix, true);
                oldbmp.recycle();
            } catch (OutOfMemoryError e) {
                Log.e("IRCCloud", "Out of memory rotating the photo, it may look wrong on imgur");
            }
        }

        if (bmp == null || !bmp.compress(android.graphics.Bitmap.CompressFormat.JPEG, 90, IRCCloudApplication
                .getInstance().getApplicationContext().getContentResolver().openOutputStream(out))) {
            out = null;
        }
        if (bmp != null)
            bmp.recycle();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        Crashlytics.logException(e);
    } catch (OutOfMemoryError e) {
        Log.e("IRCCloud", "Out of memory rotating the photo, it may look wrong on imgur");
    }
    if (!PreferenceManager.getDefaultSharedPreferences(this).getBoolean("keep_photos", false)
            && in.toString().contains("irccloudcapture")) {
        try {
            new File(new URI(in.toString())).delete();
        } catch (Exception e) {
        }
    }
    if (out != null)
        return out;
    else
        return in;
}