@@ -470,6 +470,8 @@ private class MyMediaScannerClient implements MediaScannerClient {
470470 private int mCompilation ;
471471 private boolean mIsDrm ;
472472 private boolean mNoMedia ; // flag to suppress file from appearing in media tables
473+ private int mWidth ;
474+ private int mHeight ;
473475
474476 public FileCacheEntry beginFile (String path , String mimeType , long lastModified ,
475477 long fileSize , boolean isDirectory , boolean noMedia ) {
@@ -545,6 +547,8 @@ public FileCacheEntry beginFile(String path, String mimeType, long lastModified,
545547 mWriter = null ;
546548 mCompilation = 0 ;
547549 mIsDrm = false ;
550+ mWidth = 0 ;
551+ mHeight = 0 ;
548552
549553 return entry ;
550554 }
@@ -583,6 +587,10 @@ public Uri doScanFile(String path, String mimeType, long lastModified,
583587 processFile (path , mimeType , this );
584588 }
585589
590+ if (MediaFile .isImageFileType (mFileType )) {
591+ processImageFile (path );
592+ }
593+
586594 result = endFile (entry , ringtones , notifications , alarms , music , podcasts );
587595 }
588596 }
@@ -697,6 +705,18 @@ public String getGenreName(String genreTagValue) {
697705 return genreTagValue ;
698706 }
699707
708+ private void processImageFile (String path ) {
709+ try {
710+ mBitmapOptions .outWidth = 0 ;
711+ mBitmapOptions .outHeight = 0 ;
712+ BitmapFactory .decodeFile (path , mBitmapOptions );
713+ mWidth = mBitmapOptions .outWidth ;
714+ mHeight = mBitmapOptions .outHeight ;
715+ } catch (Throwable th ) {
716+ // ignore;
717+ }
718+ }
719+
700720 public void setMimeType (String mimeType ) {
701721 if ("audio/mp4" .equals (mMimeType ) &&
702722 mimeType .startsWith ("video" )) {
@@ -725,6 +745,11 @@ private ContentValues toValues() {
725745 map .put (MediaStore .MediaColumns .MIME_TYPE , mMimeType );
726746 map .put (MediaStore .MediaColumns .IS_DRM , mIsDrm );
727747
748+ if (mWidth > 0 && mHeight > 0 ) {
749+ map .put (MediaStore .MediaColumns .WIDTH , mWidth );
750+ map .put (MediaStore .MediaColumns .HEIGHT , mHeight );
751+ }
752+
728753 if (!mNoMedia ) {
729754 if (MediaFile .isVideoFileType (mFileType )) {
730755 map .put (Video .Media .ARTIST , (mArtist != null && mArtist .length () > 0
0 commit comments