First final working version with image resize