简体   繁体   English

使用EXTERNAL_CONTENT_URI从图库中选择的图像中缺少EXIF信息

[英]Missing EXIF info in images selected from gallery using EXTERNAL_CONTENT_URI

I'm trying to gather EXIF info (date of picture taken, geotagging, orientation) from images selected from an EXTERNAL_CONTENT_URI intent, but it seems that if the pictures come from the internet (eg Google Photos) the EXIF data is somehow truncated. 我正在尝试从从EXTERNAL_CONTENT_URI意向中选择的图像中收集EXIF信息(拍摄日期,地理标记,方向),但似乎如果这些图像来自互联网(例如Google相册),则EXIF数据会被截断。

For example if I download a picture from a web browser from photos.google.com on my PC, its size is 4.377.104 bytes, and all the EXIF data are there. 例如,如果我从PC上的photos.google.com从网络浏览器下载图片,则图片大小为4.377.104字节,并且所有EXIF数据都在那里。 While if I download the same exact image using the command: 如果我使用以下命令下载相同的图像:

Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

its size is 4.363.578 bytes (13526 bytes less than the original) and all the EXIF data are lost 其大小为4.363.578字节(比原始大小少13526字节),并且所有EXIF数据均丢失

Any idea on how to download the full original image? 关于如何下载完整原始图像的任何想法吗?

PS: if I select a picture from the gallery which was taken from the phone and it is still resident on the phone's storage, the EXIF data are present PS:如果我从图库中选择了从手机上拍摄的图片,但该图片仍驻留在手机的存储空间中,则存在EXIF数据

I finally found out a solution. 我终于找到了解决方案。 after getting the source image Uri in the onActivityResult method using 使用onActivityResult方法获取源图像Uri之后

Uri selectedImage = data.getData(); 

I use the following function to get the necessary data from the picture 我使用以下功能从图片中获取必要的数据

public static ImageInfo getImageInfo(Context context, Uri photoUri) {

        Cursor cursor = context.getContentResolver().query(photoUri,
                new String[] {
                        MediaStore.Images.ImageColumns.ORIENTATION,
                        MediaStore.Images.ImageColumns.LATITUDE,
                        MediaStore.Images.ImageColumns.LONGITUDE,
                        MediaStore.Images.ImageColumns.DATE_TAKEN } , null, null, null);

        if (cursor.getCount() != 1) {
            return null;
        }

        cursor.moveToFirst();

        ImageInfo i = new ImageInfo();
        i.Orientation = cursor.getInt(0);
        i.Lat = cursor.getDouble(1);
        i.Lon = cursor.getDouble(2);
        i.DateTakenUTC = cursor.getLong(3)/1000;

        cursor.close();

        return i;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:EXTERNAL_CONTENT_URI足够用于照片库吗? - Android: Is EXTERNAL_CONTENT_URI enough for a photo gallery? 播放列表不是使用contentresolver在EXTERNAL_CONTENT_URI上创建的 - playlist is not created on EXTERNAL_CONTENT_URI using contentresolver Android中EXTERNAL_CONTENT_URI的文件路径 - Filepath of EXTERNAL_CONTENT_URI in Android EXTERNAL_CONTENT_URI和INTERNAL_CONTENT_URI都从Android的内部存储卡中提取视频 - EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI both fetch videos from internal memory card in android 查询 MediaStore.Images.Media ,如何同时查询 EXTERNAL_CONTENT_URI 和 INTERNAL_CONTENT_URI? - Querying MediaStore.Images.Media , how do I query both on EXTERNAL_CONTENT_URI and INTERNAL_CONTENT_URI? Android从内容URI获取EXIF数据 - Android get EXIF data from content URI 从图库Orientation中选择的Android图像始终为0:Exif TAG - Android image selected from gallery Orientation is always 0 : Exif TAG 使用android中的MultipleImageSelect库从图库中获取选定图像的路径 - get path of selected images from gallery using MultipleImageSelect library in android 如何在 android 工作室中使用声音云从图库中选择裁剪图像的 uri - how to get the uri of a cropped image selected from gallery using sound cloud in android studio 我想在Android图像中读取exif信息。 我可以从图库中的图像读取exif,但无法读取从相机拍摄的exif照片 - I want to read exif info in image in android. I can read exif from image in gallery but i cannot read exif photo taken from the camera
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM