Skip to content
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

Fix label size #21

Merged
merged 5 commits into from
Jun 8, 2023
Merged

Conversation

evmosseveld
Copy link
Contributor

No description provided.

@SchrodingersGat
Copy link
Member

@evmosseveld what tape sizes have you tested this on?

@evmosseveld
Copy link
Contributor Author

evmosseveld commented Jun 5, 2023

@evmosseveld what tape sizes have you tested this on?

Currently I only have the 29mm x 90mm die-cut tape to test it with, so I don't know if it works for all labels. The problem I was having was that the label wouldn't print because the brother_ql library only accepts the image if it's precisely the correct size (at least for my media type, but I suspect it's the same for all die-cut tapes). So I needed to resize the image (as stated in the code ideally there would be a GUI in InvenTree to configure sizing options just as you have printing options in desktop applications for example). Also, I don't know if this would be the right place to fix this or if it would be better to fix this in the brother_ql library so that it accepts all image sizes and resizes the image itself.

@evmosseveld
Copy link
Contributor Author

Btw I was wondering which things were meant by these 2 TODOs:

# TODO: Add padding around the provided image, otherwise the label does not print correctly
# TODO: Improve label auto-scaling based on provided width and height information

The resizing I have now implemented, is that what was meant by 'padding' in the TODO?
The same goes for the auto-scaling (although the 'provided width and height' that we get are those of the label template before conversion to PDF and PNG so I don't know how useful that information would be).

# TODO: correctly handle case where label image is bigger than printable area
for media_specifications in ALL_LABELS:
if media_specifications.identifier == media_type:
printable_dimensions = media_specifications.dots_printable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will want to handle the case where printable_dimensions is not set here

if media_specifications.identifier == media_type:
printable_dimensions = media_specifications.dots_printable
printable_image = Image.new("RGB", printable_dimensions, "white")
margin_left = (printable_dimensions[0] - label_image.width) // 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should handle the case where these calculations would result in negative values

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Jun 7, 2023

Do you have some images of this working with the printer please? :) I don't have a printer available for testing right now

@evmosseveld
Copy link
Contributor Author

evmosseveld commented Jun 8, 2023

Do you have some images of this working with the printer please? :) I don't have a printer available for testing right now

Yeah here you go :) This is a printed label for a stock item. If you need any more pictures or testing I will go to the office again next week. Currently I only have the 29x90 die cut labels to test it with unfortunately, but I think the resizing will work fine for other sizes as well.
20230607_154352
20230607_154433
20230607_154545

@SchrodingersGat
Copy link
Member

@evmosseveld thanks for the improvements, I'll push a new release

@SchrodingersGat SchrodingersGat merged commit fb7901c into inventree:main Jun 8, 2023
1 check passed
@evmosseveld evmosseveld deleted the fix_label_size branch June 8, 2023 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants