christopher-ramirez / secretary

Take the power of Jinja2 templates to OpenOffice and LibreOffice.
Other
190 stars 48 forks source link

Added Markdown Image Support #24

Closed bijanebrahimi closed 8 years ago

bijanebrahimi commented 8 years ago

Hi, I just added image support for markdown_filter which for my work was very essential. I hope we can work around to find a way to push the changes to your repo to be more publicly available.

The Only thing that I'm not very happy about my design is it uses a _dpi configuration value. apparently ODF uses inch unit over pixel and the only way to resize images (width/height) from markdown to ODT with proper inch values is to use a default dpi which derived from my understanding of dpi concept. Anyhow, i used the dpi of 200 which seemed fine by my tests and offered a customize _dpi configuration for other values!

res=engine.render('simple_template.odt',
                  _dpi=300))

I explained it Here as well!

christopher-ramirez commented 8 years ago

Hello @bijanebrahimi thank for your contributions!

I've haven't inspect your code in detail so for now I can't comment on that. I'm afraid to use a constant dpi value as your proposing since multiples images in a single document can have distinct dpi values.

The only way I know for now to obtain the dpi value of a image is using Pillow or PIL libraries. This is a problem since I can't add any of these libraries to Secretary due to they relay on native libraries, which sometimes are difficult to compile.

I would like to know your comments on these thoughts.

Kind regards, Chris.

bijanebrahimi commented 8 years ago

@christopher-ramirez I agree! I can't think of another solution right now. I'm heavily working on some other features. I just added footnote support in markdown which was another priority.

The other option that I Tested was to use a default image size for specific templates which was for limited scenarios OK. here you can see one of my works here!

christopher-ramirez commented 8 years ago

Nice job! :+1:

christopher-ramirez commented 8 years ago

Sorry for my late response. I'm afraid that for now I can't merge your changes to the repo. My decision is based on mainly on the following reasons:

  1. Image support in markdown is still not a standard.
  2. Your current implementation only supports PNG, GIF and JPG images. Libreoffice by default support at least a docent of formats.
  3. Issues previously discussed about the proper sizing of images. This relates to the dpi issue discussed above.

Regards, Chris.

bijanebrahimi commented 8 years ago

for the first one, I'm not sure about Image support being Standard or not but it's hard to find a markdown module not to convert Images to HTML img tag anyway. about the the other two I think it's about details in implementation. I should find time to change the design to satisfy the problems above.

thanks for the time :)