i'm showing images in my flutter app using
Image.network('link...')
I want to show to the user how old is that image, using the exif, showing the modification/creation time of that file, or another way around
final ByteData bytes = await rootBundle.load('assets/jpg/your_image.jpg');
var list = bytes.buffer.asUint8List();
final data = await readExifFromBytes(list);
For more, read exif
Related
I'm trying to display an image stored as blob in flutter. I'm using a PHP API to get the image and send it as a base64 string. When the image builds, there is an error that says Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
Running an xampp server. PHP APIs. Flutter application run using android studio emulator
I am able to display the image on a webpage using a HTML img tag.
Image.memory(base64Decode(imagebase64string));
I expect the image to be shown on the screen
Error says
Failed decoding image. Data is either invalid, or it is encoded using an unsupported format.
You have to remove base64 header manualy:
final stripped =
imagebase64string.replaceFirst(RegExp(r'data:image/[^;]+;base64,'), '');
setState((){
data = base64.decode(stripped);
});
Then you can use data with Image.memory.
Image.memory(data)
Decode it back to a byte array from base64 and use this from dart.ui:
final codec = await ui.instantiateImageCodec(data);
final frame = await codec.getNextFrame();
return frame.image;
Or even simpler, from package:flutter/widgets.dart:
return decodeImageFromList(data);
I need upload images with 3 different thumbnails sizes.
For example I upload image and now I get one thumbnail (48x48px), and I want to have 3 sizes: 100x100px, 300x300px, 600x600px.
How can I do this? Help me please.
You can use package for that, this is best package you can use for that Image intervention
You can use this code for resizing image after uploading.
// open an image file
$img = Image::make('public/original.jpg');
// now you are able to resize the instance
$img->resize(48,48);
// finally we save the image as a new file
$img->save('public/resized.jpg');
you can get installation setups for Laravel here
Also please refer documentation here.
Please refer this below code which I'm using to resize images.
// Upload image to Disk
$pic = $request->file('image');
$name = $pic->getClientOriginalName();
$extension = $pic->getClientOriginalExtension();
$encrypted_name = md5(uniqid().time()).".".$extension; //Generate Unique name image
$pic->move("Path/to/Uploads",$encrypted_name);
// Read that image and resize that image.
$Image = "Path/to/Uploads".$image_name;
$img = \Image::make($Image)->resize(48,48);
$img->save('new_image_name');
I am using below method to convert base64 to blob:
var blobData = new Blob([base64Str], {type: 'image/png'});
Now once the image file is created using this Blob:
var imageData = new FormData();
var counter = 1;
imageData.append("file", blobData, 'file1.png');
I do not see the metadata. Is there a way to add the metadata being stripped off the image file?
I download the image file created above and view it in http://metapicz.com/#landing
When viewing original image it shows the location info and other metadata, but when viewing the downloaded image it does not show any metadata.
Figured it out myself, the datatype returned from iOS native (swift) is UIImage which removed the EXIF information and only returns base64 of image data.
Changed the code to return entire image data + metadata at iOS native side.
I am getting an ImagesServiceFailureException exception from the app engine ImagesServiceFactory when specifying JPEG as the output format. It works fine when I specify PNG as the output format. I have only tried this on the app engine development server, not yet on the production server. JPEG is supposed to work according to the app engine docs.
Any idea why this doesn't work? I really don't want to use PNG because of the much greater size images relative to JPEG.
Following is my code:
byte[] sourceData = fetchBlobData(sourceKey);
Image sourceImage = ImagesServiceFactory.makeImage(sourceData);
// Image sourceImage = ImagesServiceFactory.makeImageFromBlob(thumbSourceKey);
ImagesService imagesService = ImagesServiceFactory.getImagesService();
// Create the transform and the new image
Transform resize = ImagesServiceFactory.makeResize(NEW_WIDTH,NEW_HEIGHT);
Image newImage = imagesService.applyTransform(resize, sourceImage, OutputEncoding.JPEG);
When I output as JPEG, I get the following exception:
com.google.appengine.api.images.ImagesServiceFailureException: Failed to encode image
Any help would be greatly appreciated.
i am trying to load images from facebook. if a user has set a profile picture, then the picture is a jpg, however, if a user has not set one, then the picture is a stub image in gif format. i know that wp7 does not support displaying gif images (out of the box). is there any way to detect if the final picture is a gif or not?
for example, i make a BitmapImage like this:
BitmapImage img = new BitmapImage(new Uri("https://graph.facebook.com/userid1/picture"))
for this uri, the user does not have a profile picture. so i get taken to a stub gif image at https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif.
if a user does have an image, then i request it as follows.
BitmapImage img = new BitmapImage(new Uri("https://graph.facebook.com/userid2/picture"))
for the above url i get taken to a url like this: https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/000000_1621037713_00000000_q.jpg
my question is then, once i get the BitmapImage object, img, can i determine if this is a JPG or GIF? can i convert it to a JPG if it is a gif?
i looked at some related questions, but the API discussed loaded the image asynchronously, which is not what i wanted at the moment. furthermore, there was poor documentation.
any help is appreciated.
nevermind, i followed the instructions here: Display GIF in a WP7 application with Silverlight. the user gave an excellent walk through.
what you need to do before you do what this user suggested is to download the source code from codeplex.
then you need to download BitMiracle's JPEG library from http://bitmiracle.com/libjpeg/.
go ahead and go into the /src/ImageTools directory and open up ImageTools.Phone.sln. add the ImageTools.IO.Jpeg.Phone project to the solution.
when you build the solution it will complain about not finding BitMiracle's JPEG dll, go ahead and reference that DLL for the Jpeg project. build again, and it should work.
First download the image(any) using Httprequest or Webclient and then convert to jpg or png from gif(if it is gif) in the following way.
GifDecoder gd = new GifDecoder();
ImageTools.ExtendedImage img = new ImageTools.ExtendedImage();
gd.Decode(img, stream); //stream means image stream
PngEncoder png = new PngEncoder();
png.Encode(img, isoFileStreamdownload); //isoFileStreamdownload means stream, which is used to save image in image file like(image.png))
using ImageTools.dll, ImageTools.IO.Gif.dll,ImageTools.IO.Png.dll (Images Tools)
I think it helps to you