I am currently using FFImageLoading package to do caching etc to show on the ui. I am unsure whether FFImageLoading have function to resize the image itself so i can save it and send over the internet.
It's as easy as:
var stream = await ImageService.Instance.LoadFile("someimage.png")
.DownSample(width: 200)
.AsPNGStreamAsync();
Related
I'm coding in Xamarin with SkiaSharp libraries for UWP (eventuallay Android but not ios) with VS 2019
With this code
SKBitmap signature = SKBitmap.Decode(canvasImg.Encode());
using (var image = SKImage.FromBitmap(signature))
using (var data = image.Encode(SKEncodedImageFormat.Jpeg, 80))
{
// Save data to a stream
using (var streamSign = File.OpenWrite(Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path + "\\work\\Models", "signature.jpg")))
{
data.SaveTo(streamSign);
}
}
I get a jpg file of my canvas. This is working perfectly. The issue is the image format defined with this line:
SKEncodedImageFormat.Jpeg
I need jpg format (and absolutely not png). The issue is this converter add me a black background and the black draws are invisible.
Anyone know how can i set the background added white ?
There are two possible workarounds
Convert the image to Png type and add a transparent background on it .
Refer to Adding transparency to a SKBitmap image results in black background .
Since there is no option of Jpg for SKEncodedImageFormat , we could use external tools(like paint , photoshop) to transfer the image to Png or Jpeg type .
Refer to https://social.msdn.microsoft.com/Forums/en-US/b466c566-6666-4cc9-9cdc-88d8c0032e2b/adding-transparency-to-a-skbitmap-image-results-in-black-background?forum=xamarinlibraries
I am using HTML canvas to send a dataURL to the server which is then saved to an image file using Perl. I need a jpeg or gif filetype (the only types supported by Perl module PDF::Create). However, no matter what I specify in the toDataURL I still get a PNG dataURL and can't create a jpeg or gif from this.
I'm using IE 11 in windows. Any ideas?
var imgdata = canvas.toDataURL('image/gif');
var imgdata = canvas.toDataURL('image/jpeg');
Both result in:
data:image/png;base64,iVBORw0KGgo...etc
I need a image manipulator for laravel but with only a few features:
Delete text from image (White Brush (?) )
Add text with a specific font.
Add other images in the image..
if is possible, a live view!
Any ideas of some package ?
Check out most popular image manipulation package Intervention Image.
Intervention Image is an open source PHP image handling and
manipulation library. It provides an easier and expressive way to
create, edit, and compose images and supports currently the two most
common image processing libraries GD Library and Imagick.
You can insert images into main image with insert() method, add custom text to image with text() method etc.
I'm wondering if anyone knows a good strategy for solving this problem:
I'm creating a social networking site using Laravel 4. Users can upload pictures to their own gallery. These pictures can be any shape and size but the gallery on their profile will only display a cropped and resized thumbnail of the image (200px x 200px), which you can click on to view the full image.
Im using the Laravel plugin Intervention right now, which saves the original image, then resizes and crops that image and saves it again ( so now I have 2 copies). I then display the cropped/resized image as the thumbnail that links to the full size original image. However, I find that making copies of every image will be a tedious waste of space on my server since there could be thousands of images uploaded to the site.
Is there a way to grab the original image, resize and crop it on the fly and display it only when the user loads the page without having to save the thumbnail to the server? or am I stuck with having to make a cropped copy for every image?
A great example that shows what I'm looking to achieve is the way Facebook crops pictures into squares in a users picture gallery or how they are cropped and resized on the newsfeed when a user uploads multiple images to a status.
Any advice is greatly appreciated!
Have you seen League/Glide yet? It's basically a wrapper for Intervention/Image and Intervention/ImageCache. Glide's Laravel setup video gets you set up in two minutes (pay attention to the second example).
Yes Intervention let's you manipulate and display on the fly too.
Here's a simple example (obviously you would actually do it with a controller etc)
Route::get('img/profile/picture.jpg', function(){
$img = Image::make('path/to/profile/picture.jpg');
// resize, crop, whatever
return $img->response();
});
And then you just set the right URI to this route as src of your image.
Intervention Docs
Keep in mind that this will use more server resources and make the image response take longer
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