How can i convert WriteableBitmap to jpg or some other common format? - silverlight-4.0

I have one application that allows user to do various things like rotating and scaling an image and finally when the user clicks on save, the image should get saved on the server. Everything works out fine but the problem is since I am directly saving the WriteableBitmap after converting it to bytearray using WriteableBitmapEx, the saved image is also WriteableBitmap and so I am not able to view it using common Picture Viewer.
I want my image to be saved as a JPEG. How can I do this?

Hey Ankit, here is a sample by John Papa that shows how to save WriteableBitmaps to PNG's.
http://johnpapa.net/silverlight/saving-snapshots-to-png-in-silverlight-4-and-the-webcam/
He uses two options: http://imagetools.codeplex.com/
And: http://blogs.msdn.com/b/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx
I would suggest the ImageTools route.

Related

Upload same image in different sizes - Dropzonejs

There is any possibility to upload a file with different sizes in DropzoneJs?
I'm using vue-dropzone which is made with dropzonejs and i have to upload the same file with different sizing for srcset.
Example:
I want to upload the file test.png which is 1000x500 px. There is any possibility to upload it at the same time in original resolution and also in 500x250px?
Image resizing in the browser has been a seat-of-the pants experience for a long time. Web assemblies are the way of the future for processing-intensive tasks in web apps. I came across this project the other day. It looks fantastic and I really can't wait to strip out our home-baked image resizing with canvas and replace it with this.
The usual reason for doing this is to avoid large uploads. It's a little bit weird to want to resize in the browser then upload the original. You might be better resizing on the server. You'll save bandwidth and the server libraries will be more mature than what's available on the client.
Along with the original image object you can add one more your custom resized image to the array of images by using resize config of dropzone. You can do the above on drop event or adddedFile event of dropzone.

How to save a photo location or actual photo as a class variable?

I have a class with a variable named Photo. The user is using the PhotoChooserTask to select the photo, and it is being displayed in an Image control. This part of the application, the chooser and display, works fine.
I would like to save either the location/path of the chosen photo or the actual photo so that it will be available for display into an Image control when the user ran the application later.
The whole class is saved using serialization, and I don't know how to save/serialize the photo (or the photo path) that way.
The photo should be still available to the user through the Camera Roll as well.
Any help, link or code, would be greatly appreciated.
If you're using a PhotoChooserTask you will will get a PhotoResult instance from the PhotoChooserTask.Completed event.
You can then PhotoResult.ChosenPhoto stream and save the content to a byte array (easy serialization) or a file in Isolated Storage.

Fine Uploader: resizing large files before upload?

I'm evaluating Fine Uploader compared to various other options, specifically JQuery File Upload.
I generally prefer the Fine Uploader approach as it's more lightweight, compared to JQuery File Uploader which has dependencies on Bootstrap and JQuery UI.
However it's important to be able to resize images: e.g., a user may select a large file from their camera and this may be very large - uploading the full resolution photo may take a very long time. JQuery File Upload doe this.
Additionally we don't have much use for very high resolution files.
If possible (I'm aware some browsers may not support this), I'd like to be able to resize images client size.
Is this possible?
Fine Uploader does not currently have any native support for image manipulation. This is a feature in our backlog, but we have not had many users tell us they are interested in this. This is one of the reasons why such a feature has yet to be implemented natively. There is a case, #707 that marks the start of native image-editing support for Fine Uploader. It is tentatively scheduled for 4.0.
However, you can certainly make use of FileReader and Canvas to resize the image. You can then submit this resized image as a Blob to Fine Uploader via the addFiles API method. At that point, the file has been submitted and Fine Uploader is ready to upload the item.
Essentially, the steps you would follow to handle this specific scenario, before Fine Uploader natively supports image manipulation:
Provide your own file input element(s) or make use of Fine Uploader's file/folder drag and drop support to get a handle on some files selected by the user.
Use FileReader to read the contents of the image.
FileReader will provide you with a URL for the image, assign that to the src attribute of an img element.
Draw the img onto a canvas element. This is where the resizing occurs.
Grab the URL of the resized image from the canvas element (canvas.toDataURL(...)).
Convert the URL to a Blob.
Pass the Blob to the addFiles API method of Fine Uploader.
The intent is to take care of most if not all of this for integrators such as yourself in the future by adding native image manipulation support to Fine Uploader.
Hope this helps.

How to upload photos using CakePHP 2.0

I'm developing a simple web app and I just want to allow the user to upload some pictures.
should I just store the picture url on my database table or should I upload the whole picture?
how can I validate the size of the picture being uploaded?
how can I upload the picture from my controller?
thank you all!
I would NOT store the image data in the database. I would create a Behavior that will upload the image to the image directory and store a reference to that image. The behavior can then handle size, mime type, etc. Then add a file upload form to the controller and when the data goes to the model to be saved, it will automatically upload the image and put it where it goes.
If you do not want to build your own, here is a very popular behavior that someone has built.
https://github.com/jrbasso/MeioUpload
Or you could try this simple way of doing it (check the readme.md file) :
https://github.com/malikov/cakephp2.0-image-upload

PDF or image loading on iPhone

Where I have to start if I want to load only a part of an image or pdf. So I would like to render only a part from a pdf file. How can this be done?
I would imagine that you will need to work with images rather than PDF (or convert any PDF to an image first)
Some options:
1) You could build a viewer that sends the screen size coordinates and a point on the image that requires viewing to return only the part of the image required.
2) Have a look the iPhone seadragon app (free). This uses Microsoft seadragon and Deepzoom technology that you could look at to service large images for zooming. more info on seadragon here: http://www.seadragon.com/