Thumbnails path in android

222 vues
Accéder directement au premier message non lu

purushottam yadav

non lue,
24 juil. 2021, 02:29:4724/07/2021
à Kivy users support
I am raising this as separate problem for not to confuse from  previous problem .

 I dont know  how to identify the thumbnail for particular image .
I have image captured with name IMG_20210720_001512.jpg  , how do I know thumbnail image name is 1626723980890.jpg ?

suggestions given previously  : 

1)  There may already be a SQLite database on the phone for picture thumbnails . 

=============   there is no  SQLIte database ===================

2 ) 

So the question is about Android's management of a particular type of hidden file.
I get that you can see the files, but seeing how Android associates them is not the same thing.

A couple of minutes with Google shows there appear to be two approaches.
From Python both would involve Pyjnius.

1) MediaStore        
2) ThumbnailUtils

Option 2) is not available to you because it requires a ContentResolver, you could modify p4a to include one but it is non trivial. So I expect option 1) , first  you will have to learn about a 'uri'.




I found few codes about  thumbnails  but they are in java I guess ,  and I dont know java , pyjnius too .
 
Can someone come up with python code using pyjnius and explain , what is happening in the code . I would have done this myself  but I am new to pyjnius  and  android  dev . 

Here are they 









Robert

non lue,
24 juil. 2021, 14:28:1324/07/2021
à Kivy users support
Since you are using Android < 10  consider the options I previously suggested https://groups.google.com/g/kivy-users/c/PlVAMGX5-nQ/m/mWFIeBndCQAJ

If in the future you want to run on Android >= 10 you probably don't understand that shared storage there is a data base not a file system. The file access of full size jpgs currently in your code will not work. The database is called the MediaStore. 

In practice probably the best thing to do is implement both storage models and use the appropriate one for the device. And this means you will have to learn Pyjnius, and to read the Android developer documentation examples.


purushottam yadav

non lue,
25 juil. 2021, 11:12:4925/07/2021
à Kivy users support
Can please you share any good links  to learn storage in android 9 and 10  ?

so You mean that accessing files is different completely and I should write different code for version 9 and 10 ?

is it same or different to access thumbnails  then ?

Robert

non lue,
25 juil. 2021, 15:49:5825/07/2021
à Kivy users support
>Can please you share any good links  to learn storage in android 9 and 10  ?
I shared the only link I like.

>so You mean that accessing files is different completely and I should write different code for version 9 and 10 ?
yes

>is it same or different to access thumbnails  then ?
maybe

Elliot Garbus

non lue,
25 juil. 2021, 17:40:5525/07/2021
à kivy-...@googlegroups.com

Another alternative would be to create your own thumbnails and database.  This is not memory efficient, but may meet your objectives.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/3e75f306-1e10-429e-a98c-d5256e73c56bn%40googlegroups.com.

 

purushottam yadav

non lue,
31 juil. 2021, 15:50:5431/07/2021
à Kivy users support

to get thumbnail from image but I am running into errors as you can see below with function queryMiniThumbnail() . DOCS are not  clear , I am not understanding what to pass as arguments.  I understand that I should pass LONG , not URI as 2nd argument  but   what is  origId ? origId is a long  integer but what is that value ? 

IF I  use other function   queryMiniThumbnails( ) in below code , I am not getting cursor but a                 "None"                is returned   .  

 AND 

IN both functions , what is the last argument to pass ? I gave   "None" , and I see no error because of it  .



===============================================     code     ============================================================


from jnius import autoclass

pythonActivity = autoclass('org.kivy.android.PythonActivity')
ContentResolver = pythonActivity.mActivity
Jint = autoclass('java.lang.Integer')

JString = autoclass('java.lang.String')
Context = autoclass('android.content.ContentResolver')
File = autoclass('java.io.File')
Uri = autoclass('android.net.Uri')



        thumb = autoclass('android.provider.MediaStore$Images$Thumbnails')

        print(dir(thumb))
        pathCursor = thumb.queryMiniThumbnail(ContentResolver.getContentResolver() , Uri.fromFile(File("/storage/emulated/0/DCIM/Camera/IMG_20210720_001512.jpg") ) , Jint.valueOf(int(thumb.MICRO_KIND )) ,  None )     #THIS IS LINE 200 IN TEXT EDITOR 
        print(pathCursor)




        if pathCursor is not None and pathCursor.movetoFirst():
            filenameIndex = pathCursor.getColumnIndex(projection.DATA)
            fileName = pathCursor.getString(filenameIndex)
            copiedFile = File(fileName)
            print(copiedFile.getParentFile())
        else:
             print("no pathhhh>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+++++++++++++++++++++++++++++++++++++++")


=====================================================      error      =============================================================



08-01 00:13:43.653 13019 13019 I python  : ['DATA', 'DEFAULT_SORT_ORDER', 'EXTERNAL_CONTENT_URI', 'FULL_SCREEN_KIND', 'HEIGHT', 'IMAGE_ID', 'INTERNAL_CONTENT_URI', 'KIND', 'MICRO_KIND', 'MINI_KIND', 'THUMB_DATA', 'WIDTH', '_COUNT', '_ID', '__class__', '__cls_storage', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__javaclass__', '__javaconstructor__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__pyx_vtable__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'cancelThumbnailRequest', 'clone', 'equals', 'finalize', 'getClass', 'getContentUri', 'getThumbnail', 'hashCode', 'identityHashCode', 'identityHashCodeNative', 'internalClone', 'notify', 'notifyAll', 'query', 'queryMiniThumbnail', 'queryMiniThumbnails', 'toString', 'wait']
08-01 00:13:43.655 13019 13019 I python  :  Traceback (most recent call last):
08-01 00:13:43.655 13019 13019 I python  :    File "jnius/jnius_proxy.pxi", line 50, in jnius.jnius.PythonJavaClass.invoke
08-01 00:13:43.655 13019 13019 I python  :    File "jnius/jnius_proxy.pxi", line 76, in jnius.jnius.PythonJavaClass._invoke
08-01 00:13:43.656 13019 13019 I python  :    File "/home/purushottam2/Desktop/project/tttt/yyy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/android/permissions.py", line 444, in onRequestPermissionsResult
08-01 00:13:43.656 13019 13019 I python  :    File "/home/purushottam2/Desktop/project/tttt/yyy/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/myapp/android/permissions.py", line 527, in python_callback
08-01 00:13:43.656 13019 13019 I python  :    File "/home/purushottam2/Desktop/project/tttt/yyy/.buildozer/android/app/main.py", line 112, in call__back
08-01 00:13:43.656 13019 13019 I python  :    File "/home/purushottam2/Desktop/project/tttt/yyy/.buildozer/android/app/main.py", line 200, in loadaddress
08-01 00:13:43.656 13019 13019 I python  :    File "jnius/jnius_export_class.pxi", line 763, in jnius.jnius.JavaMethod.__call__
08-01 00:13:43.656 13019 13019 I python  :    File "jnius/jnius_conversion.pxi", line 52, in jnius.jnius.populate_args
08-01 00:13:43.656 13019 13019 I python  :  TypeError: an integer is required
08-01 00:13:43.657 13019 13019 W Activity: Slow Operation: Activity org.test.myapp/org.kivy.android.PythonActivity onActivityResult took 781ms
08-01 00:13:43.657 13019 13019 V PythonActivity: onResume()

Robert

non lue,
31 juil. 2021, 18:01:2531/07/2021
à Kivy users support
Congrats on getting up to speed on pyjnius 😀

As I understand it there are two issues:

A) The last argument to queryMiniThumbnail() is a "String[] projection ".
  It is probably safe to specify None or []

B) queryMiniThumbnail() returns None

Does ContentResolver.getContentResolver() return None? That is what I would expect, but maybe .....

purushottam yadav

non lue,
5 août 2021, 05:03:2905/08/2021
à Kivy users support
NO , It is not returning None .


        

from jnius import autoclass

pythonActivity = autoclass('org.kivy.android.PythonActivity')
ContentResolver = pythonActivity.mActivity
Jint = autoclass('java.lang.Integer')

JString = autoclass('java.lang.String')
Context = autoclass('android.content.ContentResolver')
File = autoclass('java.io.File')
Uri = autoclass('android.net.Uri')



        thumb = autoclass('android.provider.MediaStore$Images$Thumbnails')

        print(dir(thumb))
        print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
        print(ContentResolver.getContentResolver() )


        print(dir(ContentResolver.getContentResolver() ) )



        pathCursor = thumb.queryMiniThumbnails(ContentResolver.getContentResolver() , Uri.fromFile(File('/storage/emulated/0/DCIM/Camera/IMG_20210720_001512.jpg') ) , Jint.valueOf(int(thumb.MINI_KIND )) ,  [] )
        print(pathCursor)
        print( Uri.fromFile(File('/storage/emulated/0/DCIM/Camera/IMG_20210720_001512.jpg') ))
        print(Jint.valueOf(int(thumb.MINI_KIND )))


        if pathCursor is not None and pathCursor.movetoFirst():
            filenameIndex = pathCursor.getColumnIndex(thumb.DATA)
            fileName = pathCursor.getString(filenameIndex)
            copiedFile = File(fileName)
            print(copiedFile.getParentFile())
        else:
             print("no pathhhh>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+++++++++++++++++++++++++++++++++++++++")




==========================   terminal   logs ================================================


08-05 13:23:38.057 23352 23352 I python  : ['DATA', 'DEFAULT_SORT_ORDER', 'EXTERNAL_CONTENT_URI', 'FULL_SCREEN_KIND', 'HEIGHT', 'IMAGE_ID', 'INTERNAL_CONTENT_URI', 'KIND', 'MICRO_KIND', 'MINI_KIND', 'THUMB_DATA', 'WIDTH', '_COUNT', '_ID', '__class__', '__cls_storage', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__javaclass__', '__javaconstructor__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__pyx_vtable__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'cancelThumbnailRequest', 'clone', 'equals', 'finalize', 'getClass', 'getContentUri', 'getThumbnail', 'hashCode', 'identityHashCode', 'identityHashCodeNative', 'internalClone', 'notify', 'notifyAll', 'query', 'queryMiniThumbnail', 'queryMiniThumbnails', 'toString', 'wait']
08-05 13:23:38.057 23352 23352 I python  : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

08-05 13:23:38.058 23352 23352 I python  : <android.content.ContentResolver at 0xc9622578 jclass=android/content/ContentResolver jself=<LocalRef obj=0x469a at 0xc9665fd0>>

08-05 13:23:38.058 23352 23352 I python  : ['ACTION_SYNC_CONN_STATUS_CHANGED', 'ANY_CURSOR_ITEM_TYPE', 'CONTENT_SERVICE_NAME', 'CURSOR_DIR_BASE_TYPE', 'CURSOR_ITEM_BASE_TYPE', 'EXTRA_HONORED_ARGS', 'EXTRA_REFRESH_SUPPORTED', 'EXTRA_SIZE', 'EXTRA_TOTAL_COUNT', 'NOTIFY_SKIP_NOTIFY_FOR_DESCENDANTS', 'NOTIFY_SYNC_TO_NETWORK', 'QUERY_ARG_LIMIT', 'QUERY_ARG_OFFSET', 'QUERY_ARG_SORT_COLLATION', 'QUERY_ARG_SORT_COLUMNS', 'QUERY_ARG_SORT_DIRECTION', 'QUERY_ARG_SQL_SELECTION', 'QUERY_ARG_SQL_SELECTION_ARGS', 'QUERY_ARG_SQL_SORT_ORDER', 'QUERY_SORT_DIRECTION_ASCENDING', 'QUERY_SORT_DIRECTION_DESCENDING', 'SCHEME_ANDROID_RESOURCE', 'SCHEME_CONTENT', 'SCHEME_FILE', 'SYNC_ERROR_AUTHENTICATION', 'SYNC_ERROR_CONFLICT', 'SYNC_ERROR_INTERNAL', 'SYNC_ERROR_IO', 'SYNC_ERROR_PARSE', 'SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS', 'SYNC_ERROR_TOO_MANY_DELETIONS', 'SYNC_ERROR_TOO_MANY_RETRIES', 'SYNC_EXEMPTION_NONE', 'SYNC_EXEMPTION_PROMOTE_BUCKET', 'SYNC_EXEMPTION_PROMOTE_BUCKET_WITH_TEMP', 'SYNC_EXTRAS_ACCOUNT', 'SYNC_EXTRAS_DISALLOW_METERED', 'SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS', 'SYNC_EXTRAS_DO_NOT_RETRY', 'SYNC_EXTRAS_EXPECTED_DOWNLOAD', 'SYNC_EXTRAS_EXPECTED_UPLOAD', 'SYNC_EXTRAS_EXPEDITED', 'SYNC_EXTRAS_FORCE', 'SYNC_EXTRAS_IGNORE_BACKOFF', 'SYNC_EXTRAS_IGNORE_SETTINGS', 'SYNC_EXTRAS_INITIALIZE', 'SYNC_EXTRAS_MANUAL', 'SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS', 'SYNC_EXTRAS_PRIORITY', 'SYNC_EXTRAS_REQUIRE_CHARGING', 'SYNC_EXTRAS_UPLOAD', 'SYNC_OBSERVER_TYPE_ACTIVE', 'SYNC_OBSERVER_TYPE_ALL', 'SYNC_OBSERVER_TYPE_PENDING', 'SYNC_OBSERVER_TYPE_SETTINGS', 'SYNC_OBSERVER_TYPE_STATUS', 'SYNC_VIRTUAL_EXTRAS_EXEMPTION_FLAG', '__class__', '__cls_storage', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__javaclass__', '__javaconstructor__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__pyx_vtable__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'acquireContentProviderClient', 'acquireExistingProvider', 'acquireProvider', 'acquireUnstableContentProviderClient', 'acquireUnstableProvider', 'addPeriodicSync', 'addStatusChangeListener', 'appNotRespondingViaProvider', 'applyBatch', 'bulkInsert', 'call', 'cancelSync', 'cancelSyncAsUser', 'canonicalize', 'clone', 'contentService', 'createSqlQueryBundle', 'createSqlSortClause', 'currentSync', 'currentSyncs', 'delete', 'equals', 'finalize', 'getCache', 'getClass', 'getContentService', 'getCurrentSync', 'getCurrentSyncs', 'getCurrentSyncsAsUser', 'getIsSyncable', 'getIsSyncableAsUser', 'getMasterSyncAutomatically', 'getMasterSyncAutomaticallyAsUser', 'getOutgoingPersistedUriPermissions', 'getPackageName', 'getPeriodicSyncs', 'getPersistedUriPermissions', 'getResourceId', 'getStreamTypes', 'getSyncAdapterPackagesForAuthorityAsUser', 'getSyncAdapterTypes', 'getSyncAdapterTypesAsUser', 'getSyncAutomatically', 'getSyncAutomaticallyAsUser', 'getSyncStatus', 'getSyncStatusAsUser', 'getTargetSdkVersion', 'getType', 'getTypeDrawable', 'getUserId', 'hashCode', 'identityHashCode', 'identityHashCodeNative', 'insert', 'internalClone', 'invalidPeriodicExtras', 'isSyncActive', 'isSyncPending', 'isSyncPendingAsUser', 'masterSyncAutomatically', 'maybeLogQueryToEventLog', 'maybeLogUpdateToEventLog', 'notify', 'notifyAll', 'notifyChange', 'openAssetFileDescriptor', 'openFileDescriptor', 'openInputStream', 'openOutputStream', 'openTypedAssetFileDescriptor', 'outgoingPersistedUriPermissions', 'packageName', 'persistedUriPermissions', 'putCache', 'query', 'refresh', 'registerContentObserver', 'releasePersistableUriPermission', 'releaseProvider', 'releaseUnstableProvider', 'removePeriodicSync', 'removeStatusChangeListener', 'requestSync', 'requestSyncAsUser', 'resolveUserId', 'samplePercentForDuration', 'setIsSyncable', 'setMasterSyncAutomatically', 'setMasterSyncAutomaticallyAsUser', 'setSyncAutomatically', 'setSyncAutomaticallyAsUser', 'startSync', 'syncAdapterTypes', 'syncErrorStringToInt', 'syncErrorToString', 'takePersistableUriP
08-05 13:23:38.060 23352 23352 I python  : None
08-05 13:23:38.061 23352 23352 I python  : <android.net.Uri at 0xc99f3438 jclass=android/net/Uri jself=<LocalRef obj=0x4642 at 0xc8381230>>
08-05 13:23:38.061 23352 23352 I python  : 1
08-05 13:23:38.061 23352 23352 I python  : no pathhhh>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+++++++++++++++++++++++++++++++++++++++
08-05 13:23:38.061 23352 23352 V PythonActivity: onResume()
08-05 13:23:38.061 23352 23352 V SDL     : onResume()
08-05 13:23:38.063  2305  2402 V UiModeManager: switch night mode to 1
08-05 13:23:38.065  2515  2515 D GestureStubView: resetRenderProperty: showGestureStub
08-05 13:23:38.065  2515  2515 D GestureStubView: showGestureStub
08-05 13:23:38.065  2515  2515 D GestureStubView: resetRenderProperty: showGestureStub

Robert

non lue,
5 août 2021, 12:49:4605/08/2021
à Kivy users support
OK, then I have no suggestion.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message