<p>We're using ffmpeg to batch out some TIFF images that are being resized and having white borders created to fit specific paper sizes.</p>
<p>The resulting images default to 72dpi, even when the source is 300dpi. Is there a way to set the dpi flag in the output file?</p>
<p>Many thanks :-)</p>
<p>Edit:</p>
<p>I have managed to answer my own question:</p>
<pre><code>for %%a in (&quot;*.tif&quot;) do ffmpeg -i &quot;%%a&quot; -vf &quot;scale=6974:4919:force_original_aspect_ratio=decrease,pad=7016:4961:(ow-iw)/2:(oh-ih)/2:color=white,format=rgb24&quot; -dpi 300 &quot;%%~na A2 poster 594x420mm-Border.tif&quot;
</code></pre>

CC BY-SA 4.0
2023-03-17T06:48:44.210Z
You might want to add imagemagick to the pipeline to set the dpi, I don't think there's anything in ffmpeg that deals with DPI at all.
stib
CC BY-SA 4.0
2023-03-17T21:07:34.197Z
Many thanks stib - I'd been looking at ImageMagick. It seems like that is the way to go!
jim_e_jib
<ffmpeg>
Setting dpi flag in image files generated using ffmpeg
jim_e_jib
# Setting dpi flag in image files generated using ffmpeg

(Asked by: username_0 on 2023-03-15)

We're using ffmpeg to batch out some TIFF images that are being resized and having white borders created to fit specific paper sizes.
The resulting images default to 72dpi, even when the source is 300dpi. Is there a way to set the dpi flag in the output file?
Many thanks :-)
Edit:
I have managed to answer my own question:
for %%a in ("*.tif") do ffmpeg -i "%%a" -vf "scale=6974:4919:force_original_aspect_ratio=decrease,pad=7016:4961:(ow-iw)/2:(oh-ih)/2:color=white,format=rgb24" -dpi 300 "%%~na A2 poster 594x420mm-Border.tif"

**Tags:** ffmpeg

> **Comments:**
> **username_1**: You might want to add imagemagick to the pipeline to set the dpi, I don't think there's anything in ffmpeg that deals with DPI at all.  
> **username_0**: Many thanks username_1 - I'd been looking at ImageMagick. It seems like that is the way to go!  

---

## 0 answers

