c# - determine jpeg filesize without actually saving the jpeg -
i have image in png or bmp format. find out filesize of image after compressing jpeg without saving jpeg.
up did following way:
framenormal.save("temp.jpg", imageformat.jpeg); tempfile = new fileinfo("temp.jpg"); filesizejpg = tempfile.length; but because of slow disk access, program takes long. there way calculate filesize of newly created jpeg? converting png in memory , read size...
any appreciated :-)
you can write image data stream instead of supplying filename:
using (memorystream mem = new memorystream()) { framenormal.save(mem, imageformat.jpeg); filesizejpg = mem.length; }
Comments
Post a Comment