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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -