#!/usr/bin/python
import vdrlogo,struct

def convert_img(logopath):
	print(logopath)
	with open(logopath, 'rb') as f:
		data = f.read()
	
	#get size
	w, h = struct.unpack('>LL', data[16:24])
	
	#create white png
	vdrlogo.run_cmd("convert -size " + str(w) + "x" + str(h) + " xc:white bckgr.png")

	#flatten pngs
	vdrlogo.run_cmd('convert -flatten bckgr.png "' + logopath + '" temp.png')
	
	#resize to 132x99
	vdrlogo.run_cmd('convert -resize 132x99 temp.png "' + logopath +'"')

@@ -26,16 +26,20 @@
 vdrlogo,
+sys,
 struct%0A%0A
@@ -66,133 +66,147 @@
 path
-):%0A%09print(logopath)%0A%09
+,size):%0A%09try:%0A%09%09vdrlogo.logo_
 wi
+d
 th 
-open(logopath, 'rb') as f:%0A%09%09data = f.read()%0A%09%0A%09#get size%0A%09w, h = struct.unpack('%3ELL', data%5B16:24%5D)
+= int(size.split(%22x%22)%5B0%5D)%0A%09%09vdrlogo.logo_height = int(size.split(%22x%22)%5B1%5D)%0A%09except AttributeError:%0A%09%09pass
 %0A%09%0A%09
@@ -267,24 +267,59 @@
 str(
-w) + %22x%22 + str(h
+vdrlogo.logo_width) + %22x%22 + str(vdrlogo.logo_height
 ) + 
@@ -348,20 +348,14 @@
 %0A%0A%09#
-flatten pngs
+resize
 %0A%09vd
@@ -382,25 +382,78 @@
 rt -
-flatten bckgr.png
+resize ' + str(vdrlogo.logo_width) + 'x' + str(vdrlogo.logo_height)+ '
  %22' 
@@ -468,89 +468,253 @@
 th +
- 
 '%22 
-temp.png')%0A%09%0A%09#resize to 132x99%0A%09vdrlogo.run_cmd('convert -resize 132x99 temp
+resized.png')%0A%0A%09with open(%22resized.png%22, 'rb') as f:%0A%09%09data = f.read()%0A%09%0A%09#get size%0A%09w, h = struct.unpack('%3ELL', data%5B16:24%5D)%0A%0A%09#flatten pngs%0A%09vdrlogo.run_cmd('convert -page +0+'+ str(vdrlogo.logo_height/2-(h/2)) +' -flatten bckgr.png resized
 .png
@@ -729,13 +729,14 @@
 gopath +
+ 
 '%22')%0A

Update imagemagix.py