@john95 Thank you for your interest in our product. Aspose.Imaging allows you to load images from either a file or a stream. You can try to write the binary data you have to a MemoryStream and then load a RasterImage from this stream and once you have loaded your image, you can easily resize it using the methods outlined in the documentation you mentioned. Hope this helps.
@Alexey.Karpenko Thank you very much Alexey!
It’s working, but occurred another question related to this:
After successful converting to byte array to MemoryStream I tried to use Bilinear/Neighbour resampling algorithm and I generated (saved) new jpg picture into file system. But if I open this new jpg file, then I can see only part of the picture and rest of it is black. So it seems that it worked only in the beginning and then it stopped.
Sample of my C# code:
public static void LoadImage()
{
string varbinaryString = “0xFFD8FFE000104A46494600010101004800480000FFE1214E4578696600004D4D002A…”;
var no_0x_varbinary_str = varbinaryString.Replace(“0x”, “”).Trim();
byte[] bytes = Enumerable.Range(0, no_0x_varbinary_str.Length / 2)
.Select(x => Convert.ToByte(no_0x_varbinary_str.Substring(x * 2, 2), 16))
.ToArray();
using (MemoryStream ms = new MemoryStream(bytes))
{
Aspose.Imaging.LoadOptions options = new LoadOptions();
using (Aspose.Imaging.Image asposeImage = Aspose.Imaging.Image.Load(ms))
{
asposeImage.Resize(asposeImage.Width / 2, asposeImage.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
asposeImage.Save(dir + “OutcomeBilinear.jpg”);
}
}
}
and in Main I just call this LoadImage method (after using valid Aspose licence of course).
But result is incomplete image. (I can see 5% of the image, rest is black)
Hello @john95,
We have investigated this issue and it seems that there is a problem with the image in its varbinary form. You can check this by saving the image byte array using File.WriteAllBytes("OutcomeBilinear.jpg", bytes);.
This image only contains the top 5% of its original content.