I am confused by the question. Are you getting black in the output to PNG or for output to JPG. Note that JPG does not support transparency. If you are getting black where your input was transparent and the output is PNG, then please post a link to your input and output image and the exact command line using real image names.
If you want a transparent background for your code, then use
Code: Select all
convert "$read_path" -thumbnail ${height}x${width} -background none -gravity center -extent ${height}x${width} "$write_path"
or
convert "$read_path" -thumbnail ${height}x${width} -background "#00000000" -gravity center -extent ${height}x${width} "$write_path"
If you want a white background and have transparency in the input image, then try
Code: Select all
convert "$read_path" -thumbnail ${height}x${width} -background "FFFFFFFF" -gravity center -extent ${height}x${width} "$write_path"
Note I have specified the hex color with 8 values, the last two are for tranparency and in this case fully opaque
Note, also that you can write to PNG8:outputimage.png and get 8-bit color with binary transparency as a smaller file size, though not as small as jpg. But again jpg does not support transparency. If you need 8-bit transparency, then you need to write to 32-but PNG as PNG32:outputimage.png if it does not default when just using outputimage.png