Fixed support of non jpg images.
Replaced the public generic hook by a specific one.
Cleaned helper functions.
Separated generic and specific functions and fixed some issues.