Support complex layout options #28

Closed
opened 3 years ago by josch · 0 comments
josch commented 3 years ago
Owner

By Erik on 2016-05-23T09:44:39.346Z

I'd like to add slightly more complex layout options to img2pdf.

I do not know python at all, but already identified the critical spots layout_funand started modifying the definitions -- and had some fun learning something new.

My question is: is there a chance that a merge request would be accepted? Or is something similar already planned to implement?

Best
Erik

ALIGN

My images fit "into" the page, but are smaller than the page itself. Thus, there is whitespace on the left and right of the image (excluding the border).

To create a more realistic book layout, I would like to right-align odd pages and left-align even pages.

BORDERS

I feel that the option to define all 4 borders separately would be helpful: NORTH-EAST-WEST-BOTTOM-borders.


By Erik on 2016-05-23T21:47:22.983Z


Justification draft:

https://github.com/xErik/img2pdf


By josch on 2016-05-25T18:58:50.423Z


If you need complex layouts, then img2pdf is the wrong tool for you.

For example, to create layouts that right and left align images depending whether they are on even or odd pages, I recommend you first convert all your images using img2pdf (to make sure the conversion is lossless) and then include them in the layout you want using a latex document and pdfpages and \includepdf.

Which use case do you see for being able to specify borders on all four sides?

The purpose of img2pdf is to convert images into pdf format. For very complex layouts, you should use another tool (possibly using the pdfs created by img2pdf as input to them).


By Erik on 2016-05-25T21:24:32.415Z


Well, my use case is the creation of PDF-books with odd/even-alignment, which get uploaded to Amazon/Createspace.

My enhancement of img2pdf, link above, satisfies my use case: Creating books. So I am basically happy.

I perfectly understand that you want img2pdf to focus in a specific function set, of course.


By josch on 2016-05-26T06:04:39.622Z


So you are saying that a patch exists that implements the functionality you are talking about?


By Erik on 2016-05-26T12:02:44.650Z


Yes, I refactored your code, that's why I linked "Justification draft" above:

https://github.com/xErik/img2pdf

The new parameter is:

-j JUSTIFY, --justify JUSTIFY
                        Justify the image if and only if enough space is
                        present, horizontally and / or vertically. JUSTIFY is
                        one of northwest, north, northeast, east, center,
                        west, southeast, south, southwest or book. "book"
                        iterates between "east" and "west" justification. The
                        default is "center".

I could provide a patch, but I do not know python. So there may be many things in my code that are not python-ish and may need some review beforehand. Not sure if gitlab can integrate code hosted on github, then no patch would be necessary at all.


By josch on 2016-05-26T16:31:40.085Z


Okay, I guess you are talking about: 0b6c5a49c3

I now understand what you mean. I'm still hesitating because the code and the user interface is complicated already. I mean, if we extend img2pdf like that, then what stops the next guy to provide a patch to add some text next to every image. Then the next one comes along and wants to position or format the text. I already feared that adding the pagesize, imagesize and border options would be too much. I have to think about this.

I also see this commit: 6b9c6f6967 You reported part of that commit as a bug already. What about the other hunks of that commit? Are these bugs too or are you just shifting code around?


By Erik on 2016-05-26T19:28:45.842Z


Just shifting code around.

I understand that you want img2pdf to focus on just one task. That's ok with me, I just added what I personally need.


By josch on 2017-01-21T07:56:23.726Z


Closing as wontfix. Latex or other techniques should be used to create the desired effect.


By josch on 2017-01-21T07:56:23.993Z


Status changed to closed

*By Erik on 2016-05-23T09:44:39.346Z* I'd like to add slightly more complex layout options to img2pdf. I do not know python at all, but already identified the critical spots `layout_fun`and started modifying the definitions -- and had some fun learning something new. My question is: is there a chance that a merge request would be accepted? Or is something similar already planned to implement? Best Erik ### ALIGN My images fit "into" the page, but are smaller than the page itself. Thus, there is whitespace on the left and right of the image (excluding the border). To create a more realistic book layout, I would like to right-align odd pages and left-align even pages. ### BORDERS I feel that the option to define all 4 borders separately would be helpful: NORTH-EAST-WEST-BOTTOM-borders. --- *By Erik on 2016-05-23T21:47:22.983Z* --- Justification draft: https://github.com/xErik/img2pdf --- *By josch on 2016-05-25T18:58:50.423Z* --- If you need complex layouts, then img2pdf is the wrong tool for you. For example, to create layouts that right and left align images depending whether they are on even or odd pages, I recommend you first convert all your images using img2pdf (to make sure the conversion is lossless) and then include them in the layout you want using a latex document and pdfpages and `\includepdf`. Which use case do you see for being able to specify borders on all four sides? The purpose of img2pdf is to convert images into pdf format. For very complex layouts, you should use another tool (possibly using the pdfs created by img2pdf as input to them). --- *By Erik on 2016-05-25T21:24:32.415Z* --- Well, my use case is the creation of PDF-books with odd/even-alignment, which get uploaded to Amazon/Createspace. My enhancement of img2pdf, link above, satisfies my use case: Creating books. So I am basically happy. I perfectly understand that you want img2pdf to focus in a specific function set, of course. --- *By josch on 2016-05-26T06:04:39.622Z* --- So you are saying that a patch exists that implements the functionality you are talking about? --- *By Erik on 2016-05-26T12:02:44.650Z* --- Yes, I refactored your code, that's why I linked "Justification draft" above: https://github.com/xErik/img2pdf The new parameter is: ``` -j JUSTIFY, --justify JUSTIFY Justify the image if and only if enough space is present, horizontally and / or vertically. JUSTIFY is one of northwest, north, northeast, east, center, west, southeast, south, southwest or book. "book" iterates between "east" and "west" justification. The default is "center". ``` I could provide a patch, but I do not know python. So there may be many things in my code that are not python-ish and may need some review beforehand. Not sure if gitlab can integrate code hosted on github, then no patch would be necessary at all. --- *By josch on 2016-05-26T16:31:40.085Z* --- Okay, I guess you are talking about: https://github.com/xErik/img2pdf/commit/0b6c5a49c3bff783eea9c6ea8db314aa4fcfea22 I now understand what you mean. I'm still hesitating because the code and the user interface is complicated already. I mean, if we extend img2pdf like that, then what stops the next guy to provide a patch to add some text next to every image. Then the next one comes along and wants to position or format the text. I already feared that adding the pagesize, imagesize and border options would be too much. I have to think about this. I also see this commit: https://github.com/xErik/img2pdf/commit/6b9c6f69671f8424bb29c55a3beb3bbe3e1bac75 You reported part of that commit as a bug already. What about the other hunks of that commit? Are these bugs too or are you just shifting code around? --- *By Erik on 2016-05-26T19:28:45.842Z* --- Just shifting code around. I understand that you want img2pdf to focus on just one task. That's ok with me, I just added what I personally need. --- *By josch on 2017-01-21T07:56:23.726Z* --- Closing as wontfix. Latex or other techniques should be used to create the desired effect. --- *By josch on 2017-01-21T07:56:23.993Z* --- Status changed to closed
josch closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#28
Loading…
There is no content yet.