Only knit-picking here, but it would be more in parallel with $imagetype if you defined `$mimetype = 'image/png';`