Compress file using javascript cordova framework

556 views
Skip to first unread message

Harshal Patel

unread,
Oct 14, 2014, 8:20:10 AM10/14/14
to phon...@googlegroups.com
In my project, I'm able to capture the image via camera or gallery the size of the Image file vary to 5-6 MB based on the quality of camera or user selected image.Then I have to upload it on server.

The requirement is, before upload the file on remote server, I want to apply lossless compression on image to reduce the file size to 1-2MB so it will save internet cost of user & and my server space as well.

We can't do it at the time of calling method from navigator with options {targetHeight: xxx, targetWidth: xxx} to capture image as the application may use in various devices which has various orientations too.

Thanks for any help.

Diego La Monica

unread,
Oct 14, 2014, 4:04:56 PM10/14/14
to phon...@googlegroups.com
Using the method getPicture for Real Time Camera (SourceType: CAMERA) you can use the quality compression option. But because this parameter (quality) is not considered for images taken from the library ( read the notes here http://cordova.apache.org/docs/en/3.3.0/cordova_camera_camera.md.html#camera.getPicture  ) AFAIK the only way to do this is to write the image in a canvas element then get the canvas data uri and send to server, but beware the memory usage, because with heavy image you can stuck the app.


--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--
Diego La Monica
Web Solution Developer
Software, Web, Standard, Accessibility
IWA Member #0279702
W3C Protocols and Formats Working Group member for IWA/HWG
Web Skill Profiles WG Member (http://skillprofiles.eu )

Email: m...@diegolamonica.info
Skype: diego.la.monica
Twitter: @jast
Mobile: +393337235382
Web: http://diegolamonica.info
Reply all
Reply to author
Forward
0 new messages