Re: [android-developers] Re: Media.insertImage locked to heavy compression

2010-06-30 Thread Dianne Hackborn
The standard external storage directories have been formally defined:

http://developer.android.com/reference/android/os/Environment.html

I would
suggest using DIRECTORY_PICTURES instead of DCIM unless you really do want
to be like a camera app in that way.

MediaScannerConnection is an API that allows you to explicitly run the media
scanner:

http://developer.android.com/reference/android/media/MediaScannerConnection.html

Sample
code is here:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.html

Note
that the sample code uses some improved APIs in Froyo (and the newly defined
directory constants), but can be adjusted to work on older versions.

On Wed, Jun 30, 2010 at 8:46 AM, Streets Of Boston
wrote:

> You can put any file name in the image-provider's DATA column
> ("_data").
>
> As long as your image is in the image-provider, other gallery apps
> will see your image.
>
> If you don't add the image yourself
> (getContentProvider().insert(...)), then the MediaScanner will do this
> for you when it's run (upon remount of your SD or Phone storage).
>
> Note that using MediaStore.Images.Media.EXTERNAL_CONTENT_URI only
> allows for inserting/handling images on your SD-card. Any phone
> without an SD card (many HTC Incredibles, for example) won't run your
> app properly.
>
>
> On Jun 30, 1:18 am, Julian  wrote:
> > Thanks (belatedly) for your reply. For the time being I've stuck with
> > manually writing my images to /sdcard/DCIM/AppName, which may or may
> > not be the best solution. I haven't yet checked to see if
> > getContentProvider().insert allows you to specify the DCIM
> > subdirectory, but my guess is no. (Which is disappointing if my guess
> > is right, because the directory hierarchy and the Gallery app both
> > seem to be purpose-built for exactly that.)
> >
> > I'm quite happy writing my image files manually, provided that:
> > - this is not strongly frowned upon, and
> > - i can figure out a way to force gallery to refresh from the
> > filesystem (this may be the sticking point)
> >
> > Any thoughts?
> >
> > On Jun 21, 7:18 pm, Streets Of Boston  wrote:
> >
> >
> >
> > > Compress (Bitmap.compress) the image yourself into a file.
> > > Then use the
> > >
> getContentProvider().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
> )
> > > to insert your image into the database/content-provider.
> >
> > > When inserting, you can create a ContentValues name-value pair with
> > > MediaStore.MediaColumns.DATA for the name and the fully qualified file-
> > > path to the image for the value.
> >
> > > On Jun 20, 11:16 pm, Julian  wrote:
> >
> > > > So from what I can tell Media.insertImage is locked to heavy
> > > > compression on all images. This includes when passing in the path to
> a
> > > > photo in the filesystem. As a test I used a 3000x2000 pixel jpg which
> > > > had been previously saved at maximum quality and was ~6MB. After
> > > > passing the path to Media.insertImage, the resultant copy (still
> > > > 3000x2000) is 623KB.
> >
> > > > I passed in another copy of the 3000x2000 image, this one compressed
> > > > down to 393KB. After Media.insertImage, the image filesize is 492KB.
> >
> > > > I'm wondering if there's a way to specify the compression when images
> > > > are saved by insertImage.
> >
> > > > I'm also wondering why this is recompressing jpgs, rather than simply
> > > > copying them intoDCIM. A side-effect of opening and re-compressing
> > > > these images is that it imposes a rather low VM cap on what
> > > > insertImage can handle. I'm getting out-of-memory errors when trying
> > > > to pass the path of a 10 megapixel image.
> >
> > > > As an aside: are there any problems with a developer creating their
> > > > own file/folder structure underDCIM? Is this frowned upon?
> >
> > > > Thanks for any thoughts,
> >
> > > > Julian- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" gro

[android-developers] Re: Media.insertImage locked to heavy compression

2010-06-30 Thread Streets Of Boston
You can put any file name in the image-provider's DATA column
("_data").

As long as your image is in the image-provider, other gallery apps
will see your image.

If you don't add the image yourself
(getContentProvider().insert(...)), then the MediaScanner will do this
for you when it's run (upon remount of your SD or Phone storage).

Note that using MediaStore.Images.Media.EXTERNAL_CONTENT_URI only
allows for inserting/handling images on your SD-card. Any phone
without an SD card (many HTC Incredibles, for example) won't run your
app properly.


On Jun 30, 1:18 am, Julian  wrote:
> Thanks (belatedly) for your reply. For the time being I've stuck with
> manually writing my images to /sdcard/DCIM/AppName, which may or may
> not be the best solution. I haven't yet checked to see if
> getContentProvider().insert allows you to specify the DCIM
> subdirectory, but my guess is no. (Which is disappointing if my guess
> is right, because the directory hierarchy and the Gallery app both
> seem to be purpose-built for exactly that.)
>
> I'm quite happy writing my image files manually, provided that:
> - this is not strongly frowned upon, and
> - i can figure out a way to force gallery to refresh from the
> filesystem (this may be the sticking point)
>
> Any thoughts?
>
> On Jun 21, 7:18 pm, Streets Of Boston  wrote:
>
>
>
> > Compress (Bitmap.compress) the image yourself into a file.
> > Then use the
> > getContentProvider().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
> > )
> > to insert your image into the database/content-provider.
>
> > When inserting, you can create a ContentValues name-value pair with
> > MediaStore.MediaColumns.DATA for the name and the fully qualified file-
> > path to the image for the value.
>
> > On Jun 20, 11:16 pm, Julian  wrote:
>
> > > So from what I can tell Media.insertImage is locked to heavy
> > > compression on all images. This includes when passing in the path to a
> > > photo in the filesystem. As a test I used a 3000x2000 pixel jpg which
> > > had been previously saved at maximum quality and was ~6MB. After
> > > passing the path to Media.insertImage, the resultant copy (still
> > > 3000x2000) is 623KB.
>
> > > I passed in another copy of the 3000x2000 image, this one compressed
> > > down to 393KB. After Media.insertImage, the image filesize is 492KB.
>
> > > I'm wondering if there's a way to specify the compression when images
> > > are saved by insertImage.
>
> > > I'm also wondering why this is recompressing jpgs, rather than simply
> > > copying them intoDCIM. A side-effect of opening and re-compressing
> > > these images is that it imposes a rather low VM cap on what
> > > insertImage can handle. I'm getting out-of-memory errors when trying
> > > to pass the path of a 10 megapixel image.
>
> > > As an aside: are there any problems with a developer creating their
> > > own file/folder structure underDCIM? Is this frowned upon?
>
> > > Thanks for any thoughts,
>
> > > Julian- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Media.insertImage locked to heavy compression

2010-06-29 Thread Julian
Thanks (belatedly) for your reply. For the time being I've stuck with
manually writing my images to /sdcard/DCIM/AppName, which may or may
not be the best solution. I haven't yet checked to see if
getContentProvider().insert allows you to specify the DCIM
subdirectory, but my guess is no. (Which is disappointing if my guess
is right, because the directory hierarchy and the Gallery app both
seem to be purpose-built for exactly that.)

I'm quite happy writing my image files manually, provided that:
- this is not strongly frowned upon, and
- i can figure out a way to force gallery to refresh from the
filesystem (this may be the sticking point)

Any thoughts?

On Jun 21, 7:18 pm, Streets Of Boston  wrote:
> Compress (Bitmap.compress) the image yourself into a file.
> Then use the
> getContentProvider().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, 
> )
> to insert your image into the database/content-provider.
>
> When inserting, you can create a ContentValues name-value pair with
> MediaStore.MediaColumns.DATA for the name and the fully qualified file-
> path to the image for the value.
>
> On Jun 20, 11:16 pm, Julian  wrote:
>
>
>
> > So from what I can tell Media.insertImage is locked to heavy
> > compression on all images. This includes when passing in the path to a
> > photo in the filesystem. As a test I used a 3000x2000 pixel jpg which
> > had been previously saved at maximum quality and was ~6MB. After
> > passing the path to Media.insertImage, the resultant copy (still
> > 3000x2000) is 623KB.
>
> > I passed in another copy of the 3000x2000 image, this one compressed
> > down to 393KB. After Media.insertImage, the image filesize is 492KB.
>
> > I'm wondering if there's a way to specify the compression when images
> > are saved by insertImage.
>
> > I'm also wondering why this is recompressing jpgs, rather than simply
> > copying them intoDCIM. A side-effect of opening and re-compressing
> > these images is that it imposes a rather low VM cap on what
> > insertImage can handle. I'm getting out-of-memory errors when trying
> > to pass the path of a 10 megapixel image.
>
> > As an aside: are there any problems with a developer creating their
> > own file/folder structure underDCIM? Is this frowned upon?
>
> > Thanks for any thoughts,
>
> > Julian

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Media.insertImage locked to heavy compression

2010-06-21 Thread Streets Of Boston
Compress (Bitmap.compress) the image yourself into a file.
Then use the
getContentProvider().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, )
to insert your image into the database/content-provider.

When inserting, you can create a ContentValues name-value pair with
MediaStore.MediaColumns.DATA for the name and the fully qualified file-
path to the image for the value.


On Jun 20, 11:16 pm, Julian  wrote:
> So from what I can tell Media.insertImage is locked to heavy
> compression on all images. This includes when passing in the path to a
> photo in the filesystem. As a test I used a 3000x2000 pixel jpg which
> had been previously saved at maximum quality and was ~6MB. After
> passing the path to Media.insertImage, the resultant copy (still
> 3000x2000) is 623KB.
>
> I passed in another copy of the 3000x2000 image, this one compressed
> down to 393KB. After Media.insertImage, the image filesize is 492KB.
>
> I'm wondering if there's a way to specify the compression when images
> are saved by insertImage.
>
> I'm also wondering why this is recompressing jpgs, rather than simply
> copying them into DCIM. A side-effect of opening and re-compressing
> these images is that it imposes a rather low VM cap on what
> insertImage can handle. I'm getting out-of-memory errors when trying
> to pass the path of a 10 megapixel image.
>
> As an aside: are there any problems with a developer creating their
> own file/folder structure under DCIM? Is this frowned upon?
>
> Thanks for any thoughts,
>
> Julian

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en