locked
Convert JPG to PNG in database RRS feed

  • Question

  • I got a lof of JPG images stored in DB (as varbinary of course). How can I convert them to PNG (I hope this will save some memory)?

    Thursday, March 8, 2012 2:12 PM

Answers

  • I think JPEG are more efficient in terms size and etc.. So you need to write an application to retrieve the pictures from the table , then convert them to PNG and then save/insert into a table again

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    • Proposed as answer by Naomi N Thursday, March 8, 2012 5:38 PM
    • Marked as answer by KJian_ Thursday, March 15, 2012 5:18 AM
    Thursday, March 8, 2012 2:21 PM
    Answerer
  • I the databse:
    Not at all. Re-encoding binary data is something a client application should do, not a database server. It will also most likely have no ability for it
    As for how to do this (without ending with inconsistent data):
    Add a row "picture type" to your table. Insert the value 1 (standing for JPEG) for all rows. Retrieve a picture with your clietn programm. re-encode in the client. Write the new picture and the picture code 2 (standign for PNG) into the database.
    Loop through this, until all picutres are converted.
    Afterwards you may deleted the row again.

    Regadign the Size:
    JPG are the smalest possible format. It archives that because it is a lossy way of storing the picture information. It only serves well as an output format (putting it on a webpage). Do not use it if you later want to (professionally) edit the pictures.
    http://en.wikipedia.org/wiki/Jpg

    PNG are a lossless data picture format, that also supports layers and alpha-chanel (transparancy) and a lot other stuff that JPEG doesn't. By defintion it will take more size. It's a format you use when you want to store the picture for later editing, not your first choice when you want to publish it (unless you need transparency, wich is true for most GUI-programmers).
    http://en.wikipedia.org/wiki/Portable_Network_Graphics

    • Proposed as answer by Naomi N Thursday, March 8, 2012 5:39 PM
    • Marked as answer by KJian_ Thursday, March 15, 2012 5:18 AM
    Thursday, March 8, 2012 3:31 PM

All replies

  • I think JPEG are more efficient in terms size and etc.. So you need to write an application to retrieve the pictures from the table , then convert them to PNG and then save/insert into a table again

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    • Proposed as answer by Naomi N Thursday, March 8, 2012 5:38 PM
    • Marked as answer by KJian_ Thursday, March 15, 2012 5:18 AM
    Thursday, March 8, 2012 2:21 PM
    Answerer
  • I the databse:
    Not at all. Re-encoding binary data is something a client application should do, not a database server. It will also most likely have no ability for it
    As for how to do this (without ending with inconsistent data):
    Add a row "picture type" to your table. Insert the value 1 (standing for JPEG) for all rows. Retrieve a picture with your clietn programm. re-encode in the client. Write the new picture and the picture code 2 (standign for PNG) into the database.
    Loop through this, until all picutres are converted.
    Afterwards you may deleted the row again.

    Regadign the Size:
    JPG are the smalest possible format. It archives that because it is a lossy way of storing the picture information. It only serves well as an output format (putting it on a webpage). Do not use it if you later want to (professionally) edit the pictures.
    http://en.wikipedia.org/wiki/Jpg

    PNG are a lossless data picture format, that also supports layers and alpha-chanel (transparancy) and a lot other stuff that JPEG doesn't. By defintion it will take more size. It's a format you use when you want to store the picture for later editing, not your first choice when you want to publish it (unless you need transparency, wich is true for most GUI-programmers).
    http://en.wikipedia.org/wiki/Portable_Network_Graphics

    • Proposed as answer by Naomi N Thursday, March 8, 2012 5:39 PM
    • Marked as answer by KJian_ Thursday, March 15, 2012 5:18 AM
    Thursday, March 8, 2012 3:31 PM