def add_media(self, name, pos, x_cm, y_cm, alt='', style_name=None, crop=None): nx, ny = image_size(name) if (nx, ny) == (0,0): return (act_width, act_height) = image_actual_size(x_cm, y_cm, nx, ny) act_width = twips(act_width) act_height = twips(act_height) size = [act_width, act_height] buf = resize_to_jpeg_buffer(name, size, crop=crop) act_width = size[0] # In case it changed because of cropping or keeping the ratio act_height = size[1] self.f.write('{\*\shppict{\\pict\\jpegblip') self.f.write('\\picwgoal%d\\pichgoal%d\n' % (act_width,act_height)) index = 1 for i in buf: self.f.write('%02x' % i) if index%32==0: self.f.write('\n') index = index+1 self.f.write('}}\\par\n') if len(alt): self.f.write('%s\n\\par\n' % '\\par'.join(alt))
def add_media(self, name, pos, x_cm, y_cm, alt='', style_name=None, crop=None): width, height = image_size(name) if (width, height) == (0, 0): return (act_width, act_height) = image_actual_size(x_cm, y_cm, width, height) act_width = twips(act_width) act_height = twips(act_height) size = [act_width, act_height] buf = resize_to_jpeg_buffer(name, size, crop=crop) # The size may change because of cropping or keeping the ratio act_width = size[0] act_height = size[1] if self.in_table: self.text += '{\*\shppict{\\pict\\jpegblip' self.text += '\\picwgoal%d\\pichgoal%d\n' % (act_width, act_height) index = 1 for i in buf: self.text += '%02x' % i if index % 32 == 0: self.text += '\n' index = index + 1 self.text += '}}\\par\n' else: self.file.write('{\*\shppict{\\pict\\jpegblip') self.file.write('\\picwgoal%d\\pichgoal%d\n' % (act_width, act_height)) index = 1 for i in buf: self.file.write('%02x' % i) if index % 32 == 0: self.file.write('\n') index = index + 1 self.file.write('}}\\par\n') if len(alt): self.file.write('%s\n\\par\n' % '\\par'.join(alt))
def add_media(self, name, pos, x_cm, y_cm, alt='', style_name=None, crop=None): width, height = image_size(name) if (width, height) == (0, 0): return (act_width, act_height) = image_actual_size(x_cm, y_cm, width, height) act_width = twips(act_width) act_height = twips(act_height) size = [act_width, act_height] buf = resize_to_jpeg_buffer(name, size, crop=crop) # The size may change because of cropping or keeping the ratio act_width = size[0] act_height = size[1] if self.in_table: self.text += '{\\*\\shppict{\\pict\\jpegblip' self.text += '\\picwgoal%d\\pichgoal%d\n' % (act_width, act_height) index = 1 for i in buf: self.text += '%02x' % i if index % 32 == 0: self.text += '\n' index = index+1 self.text += '}}\\par\n' else: self.file.write('{\\*\\shppict{\\pict\\jpegblip') self.file.write('\\picwgoal%d\\pichgoal%d\n' % (act_width, act_height)) index = 1 for i in buf: self.file.write('%02x' % i) if index % 32 == 0: self.file.write('\n') index = index+1 self.file.write('}}\\par\n') if len(alt): self.file.write('%s\n\\par\n' % '\\par'.join(alt))
def add_media_object(self, name, pos, x_cm, y_cm, alt='', style_name=None, crop=None): nx, ny = image_size(name) if (nx, ny) == (0, 0): return (act_width, act_height) = image_actual_size(x_cm, y_cm, nx, ny) act_width = twips(act_width) act_height = twips(act_height) size = [act_width, act_height] buf = resize_to_jpeg_buffer(name, size, crop=crop) act_width = size[ 0] # In case it changed because of cropping or keeping the ratio act_height = size[1] self.f.write('{\*\shppict{\\pict\\jpegblip') self.f.write('\\picwgoal%d\\pichgoal%d\n' % (act_width, act_height)) index = 1 for i in buf: self.f.write('%02x' % ord(i)) if index % 32 == 0: self.f.write('\n') index = index + 1 self.f.write('}}\\par\n') if len(alt): self.f.write('%s\n\\par\n' % '\\par'.join(alt))