The goal is to setup MediaTomb to (almost) instantaneously resize a 4-7MB jpeg from its original 8 or 12MP resolution down to somewhere about 1280x* so that it can be viewed on a mobile device.

Information on my setup: VM running arch with MediaTomb and another VM running arch and BubbleUPnP server to allow me to connect to all of my UPnP servers at home wherever I am. The problem is that I don't want to convert all of the pictures I take on trips. I simply want to browse them remotely and have the images resized quickly enough that I don't notice a lag when displaying/viewing pictures. Obviously the resizing is also to decrease the time it takes to display them.

I've tried using Imagemagick and it is very slow (5-10 seconds per picture) and ffmpeg is unsuitable for images over 5,000px. What are my options here?

VM 1: 2x3.00Ghz, 768mb ram (MediaTomb) VM 2: 2x3.00Ghz, 512mb ram (XBMC, BubbleUPnP)

Original image resize script contained:

convert "$1" -filter lanczos -resize 1280x* "$2"

In the mediatomb config.xml I have added the following to their appropriate sections:
Under mimetype-profile-mappings:

<transcode mimetype="image/jpeg" using="jpeg-small"/>

And under profiles:

<profile name="jpeg-small" enabled="yes" type="external">
  <agent command="convert" arguments="%in -resize 1280x1280 %out"/>
  <buffer size="10485760" chunk-size="131072" fill-size="2621440"/>

UPDATE: Now it "works", but I can only find sub-200x200 pictures when I browse MediaTomb share from a UPnP client. Not sure why as I'm telling it to make 1280 the maximum length of a side.


It looks like mediatomb has its own method for doing this internally. Perhaps this would do what you want.


  <transcoding enabled="yes">
      <transcode mimetype="image/jpeg" using="jpeg-small"/>
      <profile name="jpeg-small" enabled="yes" type="external">
        <agent command="/opt/jpeg-resize.sh" arguments="%in %out"/>
        <buffer size="4000000" chunk-size="20000" fill-size="20000"/>

You can then resize using this script, /opt/jpeg-resize.sh:

echo "---------" >> /opt/jpeg-resize.log
echo "Input  "$1 >> /opt/jpeg-resize.log
echo "Output "$2 >> /opt/jpeg-resize.log
cat "$1" | convert - -quality "75" -resize "1920x1080" fd:1 > "$2"

Source: Transcode JPG to lower resolution.

Debugging mediatomb

If you're having problems determining what mediatomb is doing you can launch it in debug mode so that you get more verbose output.

$ mediatomb -D
  • Already doing approximately that. Convert just takes forever (I have timed it) – KG6ZVP Mar 19 '14 at 3:11
  • Got it working. I had to remove the -filter argument specifying which resize method to use. The problem now is that all the pictures are now resized to under 200x200. My command-line is: convert "$1" -resize "1280x*" "$2" What's going wrong? – KG6ZVP Mar 19 '14 at 19:07
  • @KG6ZVP - can you add more details? I can't help you more without additional info. For example what -filter argument are you referring to? Also can you show us exactly what you're doing? I use mediatomb as well and the above appears to be working fine for me. – slm Mar 19 '14 at 21:33
  • Any idea what's wrong? – KG6ZVP Mar 21 '14 at 0:50
  • @KG6ZVP - try running mediatomb -D in debug mode. – slm Mar 21 '14 at 5:59

You have not specified how you're using Imagemagick but there is no reason why it should be so slow. I just tested this on my laptop (i7, 2.67 GHz) and converted a 6.1MB .jpg to a 238K one in less than a second:

$ time convert -resize 577x577 foo.jpg bar.jpg 

real    0m0.883s
user    0m1.712s
sys     0m0.060s
$ ls -lh
total 6420
-rw-r--r-- 1 terdon terdon  238K Mar 19 03:24 bar.jpg
-rw-r--r-- 1 terdon terdon  6.1M Mar 19 03:17 foo.jpg

Just play around with the various options to get one that suits your needs.

  • Identical options on the command-line. However, the VM being used can't/won't have as much CPU power dedicated to it as your machine. It is running two cores at ~3.00Ghz each. – KG6ZVP Mar 19 '14 at 2:28
  • @KG6ZVP that's odd. As far as I know, convert does not multithread so it ran on a single, albeit i7, 2.67 core. I find it hard to believe that there can be so much difference. In any case, I don't think you can do better than the IMageMagick tools though you might be able to optimize the options more. – terdon Mar 19 '14 at 2:53
  • I'll try updating the software again. – KG6ZVP Mar 19 '14 at 2:57
  • @KG6ZVP also, please edit your question and include both your VM's specs and the exact command you are running. – terdon Mar 19 '14 at 2:59
  • Check the question again. I have added all other information – KG6ZVP Mar 21 '14 at 0:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.