-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: set image extent so that it fits on a page #16
Comments
Hi, |
Oh wow. These changes look great! Thanks so much for implementing this.
…On Jan 15, 2023 at 23:56:24, Morten ***@***.***> wrote:
Hi,
#34 <#34> implements defining a
page size manually. This would be the starting point for scaling images
(shrink to fit page, etc). #35
<#35> Is a draft of an
implementation if scaling images larger than the printable area to fit the
page. There are unfortunately still a few issues with the implementation
and I am not entirely happy how things end up in the generated .docx...
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXE3PU4ISMMNK3XZZZ6W5TWST5KRANCNFSM6AAAAAAQZDSQWU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I took a look, and your changes works great for my use cases!
I do think that a NSTextAttachment subclass that allows a client to specify
the max width/height percentage is a good idea. For instance, if I know
that my potentially-tall image is going to have a caption, I may want to
make sure it doesn’t exceed 90% of the available height. Similarly – and
maybe for the same image – I may want to make sure that it doesn’t take up
more than 50% of the available width.
As for your other comment about how the image size changes when you
copy/paste into Word – yeah, it’s weird. Some images I bring in appear at
half their original width and height. However, when I open the "Size and
Position” dialog, it seems to think that it’s displaying it at its original
size. Others – I’ve only seen this with “small” images – appear at the
expected size. And yet others – usually “larger” images – appear to be
resized to the available width; when I go into the “Size and Position”
dialog, I can see its correct “Original size” and that a “Scale” has been
applied.
Anyhow, my position would be that Word’s behavior here is not that
important. While it would be nice to understand what’s going on with those
half-sized images, it seems you’ve replicated the actually-understandable
part of their heuristic!
Thanks again for implementing this! And please let me know if my comment
about NSTextAttachment above is unclear.
…On Jan 16, 2023 at 22:18:13, Morten ***@***.***> wrote:
It would be awesome if you could have a look at #35
<#35> to check whether this
gives the desired behavior. I made a few remarks in the PR (#35
<#35>) about aspects that might
be changed / improved.
I guess further (auto-)scaling of images could be implemented in a
NSTextAttachement subclass if desired.
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADXE3PXQ6B2JKTR4HYDS4NDWSY2SLANCNFSM6AAAAAAQZDSQWU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hi Morten,
I just wanted to follow-up to this to let you know that we’ve pulled your
current change (from the Image_ScaleToFit branch), and have been using it
successfully for a while now. So, thanks again!
I was thinking that it might be nice to just pull your current change as-is
into master. I still think it would be great to implement the feature we
discussed in our previous exchange (an NSTextAttachment subclass that
allows a client to specify the max width/height), but maybe that could come
later as an additional PR?
What do you think?
…On Jan 17, 2023 at 13:56:54, Brad Andalman ***@***.***> wrote:
I took a look, and your changes works great for my use cases!
I do think that a NSTextAttachment subclass that allows a client to
specify the max width/height percentage is a good idea. For instance, if I
know that my potentially-tall image is going to have a caption, I may want
to make sure it doesn’t exceed 90% of the available height. Similarly – and
maybe for the same image – I may want to make sure that it doesn’t take up
more than 50% of the available width.
As for your other comment about how the image size changes when you
copy/paste into Word – yeah, it’s weird. Some images I bring in appear at
half their original width and height. However, when I open the "Size and
Position” dialog, it seems to think that it’s displaying it at its original
size. Others – I’ve only seen this with “small” images – appear at the
expected size. And yet others – usually “larger” images – appear to be
resized to the available width; when I go into the “Size and Position”
dialog, I can see its correct “Original size” and that a “Scale” has been
applied.
Anyhow, my position would be that Word’s behavior here is not that
important. While it would be nice to understand what’s going on with those
half-sized images, it seems you’ve replicated the actually-understandable
part of their heuristic!
Thanks again for implementing this! And please let me know if my comment
about NSTextAttachment above is unclear.
On Jan 16, 2023 at 22:18:13, Morten ***@***.***> wrote:
> It would be awesome if you could have a look at #35
> <#35> to check whether this
> gives the desired behavior. I made a few remarks in the PR (#35
> <#35>) about aspects that might
> be changed / improved.
> I guess further (auto-)scaling of images could be implemented in a
> NSTextAttachement subclass if desired.
>
> —
> Reply to this email directly, view it on GitHub
> <#16 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADXE3PXQ6B2JKTR4HYDS4NDWSY2SLANCNFSM6AAAAAAQZDSQWU>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Hi, I am glad to hear the Scale-to-Fit works well for you. I have realized that my original plan - allowing custom |
When I create a docx, I’d like for any images to fit on a single page. I realize I can resize the image on my end, but that isn’t ideal as I’d like the original image to remain untouched.
I’ve attached two docx files that illustrate the issue:
Under-the-Wave-Created-DocX.docx
Under-the-Wave-Created-Word.docx
The first docx file was created using DocX, and you can see that my image, since it is large, is pushed to the next page and also clipped. When I add the original image into Word, you can see that it is resized to fit the page. (Word also – annoyingly – resizes the original image. However, when I unzip the docx, replace the resized image with my original image, then re-created the docx file, Word still displays the image correctly.)
I’ve only looked quickly, but it seems to me that this is controlled by the wp:extent element. In the DocX package, it looks like the extent is determined by the size of the image. This seems like a great fallback. It would be nice, though, if the image was scaled to fit when the image’s width/height is greater than the page’s usable width/height (i.e. not including margins).
Bonus suggestion #1: It would also be nice if there were a way to set the image’s display width more directly. Perhaps NSTextAttachment could be extended to have a “docxExportWidthFraction” attribute. If that were set to “0.5”, then the display width would be set to 50% of the page’s usable width.
Bonus suggestion #2: When the “docxExportWidthFraction” is set, it might be nice to center the image horizontally. (Though I wouldn’t complain if images were just always centered, rather than left-aligned.)
The text was updated successfully, but these errors were encountered: