Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXIF support #172

Closed
nostra13 opened this issue Feb 15, 2013 · 26 comments
Closed

EXIF support #172

nostra13 opened this issue Feb 15, 2013 · 26 comments
Labels

Comments

@nostra13
Copy link
Owner

Consider EXIF orientation (and maybe some others parameters) of image files.

@All_Users Comment here if you need this feature

@cycDroid
Copy link

It is a nice feature, but i don't think all photos have EXIF.
As far as I know, EXIF just exists in JPEG.
I am wondering whether UIL will support GIF in the future.
Thanks, UIL is a great library.

@gildor
Copy link

gildor commented Feb 28, 2013

Very useful feature!
Needed in the current project

@yuvipanda
Copy link

+1, the official Wikimedia app uses UIL, and does need this feature! Just Orientation would be more than enough, I think? Thank you!

@nostra13
Copy link
Owner Author

the official Wikimedia app uses UIL

@yuvipanda Really? I didn't receive any notification from you :)

Ok, I'll think about this feature in near future (next lib version).

@yuvipanda
Copy link

Wikimedia Commons app :) It was released only a few weeks back, and is still in beta :) I thought of notifying you once I have an about screen in place, but it isn't there yet!

Thanks for the wonderful library :)

@nostra13
Copy link
Owner Author

You're welcome :)

@dbasal
Copy link

dbasal commented Mar 18, 2013

+1 for a rotation option. Don't think EXIF is important to me since I get the images out of the MediaStore, but it would be nice to have a display option that could be passed into the displayimage which would tell the library how to rotate the image before returning it

@IanDBird
Copy link

+1 for rotation option! :)

@xMikeTx
Copy link

xMikeTx commented Mar 26, 2013

Would appreciate the EXIF support. I sometimes get pictures from media store in the wrong orientation. Happens on Samsung Galaxy Nexus.
The Galaxy N4 does not have these issues and I cannot really narrow down the problem.

Thanx for your awesome work.

@Maragues
Copy link

This is the code I'm using to get a correctly oriented Bitmap from local path

public static Bitmap rotate(Bitmap b, int degrees) {
    if (degrees != 0 && b != null) {
      Matrix m = new Matrix();

      m.setRotate(degrees, (float) b.getWidth() / 2, (float) b.getHeight() / 2);
      try {
        Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), m, true);
        if (b != b2) {
          b.recycle();
          b = b2;
        }
      } catch (OutOfMemoryError ex) {
        throw ex;
      }
    }
    return b;
  }

  public static int getCameraPhotoOrientation(Context context, Uri imageUri, String imagePath) {
    int rotate = 0;
    try {
      context.getContentResolver().notifyChange(imageUri, null);
      File imageFile = new File(imagePath);
      ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
      int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);

      switch (orientation) {
      case ExifInterface.ORIENTATION_ROTATE_270:
        rotate = 270;
        break;
      case ExifInterface.ORIENTATION_ROTATE_180:
        rotate = 180;
        break;
      case ExifInterface.ORIENTATION_ROTATE_90:
        rotate = 90;
        break;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return rotate;
  }

Then

Bitmap b = rotate(bitmap, getCameraPhotoOrientation(context, uri, path));

It works correctly on Samsung Galaxy S, wich otherwise returns a wrong oriented bitmap.

It's not my code but a mix of several SO answers. See
http://stackoverflow.com/questions/8450539/images-taken-with-action-image-capture-always-returns-1-for-exifinterface-tag-or

http://stackoverflow.com/questions/4517634/picture-orientation-from-gallery-camera-intent

@nostra13
Copy link
Owner Author

I'm working on this right now. I have already implemented all needed logic and testing it. Will be soon.

nostra13 added a commit that referenced this issue Mar 30, 2013
Introduced ImageLoaderConfiguration.imageDecoder(...)
Introduced DisplayImageOptions.decodingOptions(...)
Made ImageDecoder as interface. Added BaseImageDecoder. Extract size and
scale calculation to ImageSizeUtils.
@yuvipanda
Copy link

Wonderful :) Thank you! Waiting for a maven release :)

@yuvipanda
Copy link

Is there an example of how to use this? I've not been able to get this to work, reading data from a contentprovider...

@andresesfm
Copy link

It worked for me, Just replace old jar with the new 1.8.4.jar

Thanks @nostra13 , great library

@nostra13
Copy link
Owner Author

@yuvipanda EXIF support should work automatically. but it works only for local files ("file://...") or if you enable disc caching.

@blinduck
Copy link

blinduck commented Aug 7, 2013

Is there an option to disable exif support? I'd like to display images without taking the orientation into account...

@nostra13
Copy link
Owner Author

nostra13 commented Aug 7, 2013

Only if you change lib sources.
I'll make it configurable in following versions.

@idish
Copy link

idish commented Aug 20, 2013

Hi nostra,
If the local file is a thumbnail from the mediastore, will the EXIF support still be ok?

@doapp-baker
Copy link

@nostra13, you mentioned above that the EXIF support only works for local files or if you enable disc caching. I can't get the EXIF parameters to be respected on external urls with disc caching enabled.

Maybe I'm looking in the wrong place, but it looks like in BaseImageDecoder that it has to be a local file url scheme (meaning I can't just enable disc caching).

if ("image/jpeg".equalsIgnoreCase(mimeType) && Scheme.ofUri(imageUri) == Scheme.FILE)

@nostra13
Copy link
Owner Author

@doapp-baker If you enabled disc caching then BaseImageDecoder gets URLs with "file" scheme according cached file path on disk cache. Did you enable disc caching? Show your display options.

@doapp-baker
Copy link

        // Create global configuration and initialize ImageLoader with this configuration
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
                .defaultDisplayImageOptions((new DisplayImageOptions.Builder())
                                                    .bitmapConfig(Bitmap.Config.RGB_565)
                                                    .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
                                                    .cacheOnDisc(true)
                                                    .cacheInMemory(true)
                                                    .build())
                .threadPoolSize(5)
                .denyCacheImageMultipleSizesInMemory()
                .discCache(new UnlimitedDiscCache(StorageUtils.getCacheDirectory(this)))
                .memoryCache(new FIFOLimitedMemoryCache(1024))
                .build();
        ImageLoader.getInstance().init(config);

@nostra13
Copy link
Owner Author

Can't say what's the problem. Maybe try to debug whether
if ("image/jpeg".equalsIgnoreCase(mimeType) && Scheme.ofUri(imageUri) == Scheme.FILE) == true

@doapp-baker
Copy link

This is a pretty bad place to get support. There are also a lot of variables here (the photo for the first 1,000). Thanks for the help. Knowing the config is right and that it should be working is a great help. Really appreciate the library, it's a LIFE SAVER.

@swatigoel
Copy link

@doapp-baker I am using Universal Image Loader library to select multiple images and display in UI.

In Samsung devices, When I open the gallery view(CustomGalleryActivity), Image orientation is not correct. If I try to rotate orientation while querying on db
Cursor imageCursor = managedQuery(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns,
null, null, orderBy);

by checking its Exif value, it worked. But it hangs the screen for sometime.

I want to rotate the image after selection coming back to show on UI(only selected images).

@swatigoel
Copy link

I have resolved this problem by using "considerExifParams(true)" while initializing DisplaytImageOption configuration.
Please refer this link #559

@black-snow
Copy link

Guess this one can be closed.

Just out of curiosity, why isn't exif orientation enabled by default? For me this is what I expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests