The behavior you're observing with the convert command (part of ImageMagick) is due to how the -flatten option interacts with multi-page PDFs.
file.png instead of file-0.png, file-1.png:-flatten merges all layers and pages into a single output image.
When you use -flatten, ImageMagick combines all pages of the PDF into one flattened image, resulting in a single output file (file.png). This is the expected behavior of -flatten: it merges everything into one image, regardless of the number of input pages.
Without -flatten, ImageMagick outputs one image per page.
If you omit -flatten, ImageMagick will generate separate output files for each page (e.g., file-0.png, file-1.png).
Remove the -flatten option:
bashconvert file.pdf file.png
This will produce file-0.png, file-1.png, etc.
Use a loop or specify the page range:
bashconvert -density 300 file.pdf[0] -flatten file-0.png convert -density 300 file.pdf[1] -flatten file-1.png
Or, in a loop:
bashfor i in $(seq 0 $(($(pdfinfo file.pdf | grep Pages | awk '{print $2}')-1))); do convert -density 300 file.pdf[$i] -flatten file-$i.png done