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

Label Image Decoding and Saving #1

Closed
jorgeepena opened this issue Nov 3, 2020 · 3 comments
Closed

Label Image Decoding and Saving #1

jorgeepena opened this issue Nov 3, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@jorgeepena
Copy link

Hey rawilk! Amazing package you have here, really helpful and the documentation is very understandable. This "issue" is more of a "feature wishlist" if you would like that kind of input :)

On the shipping class there are labels of the packages generated on the process, this "package" returns an encoded image but the documentation doesn't explain how to convert and save that to the database and project. I solved it like this:

 /* Cleaning the code */
 $image = base64_decode($packages->first()->label_image->graphic_image);

 /* Saving code as an image on a folder in the system */
 file_put_contents('img/tracking-labels/order_' . $order->id . '.gif', $image);

 /* Saving the name of the file */
 $order_package->package_label_file = 'order_' . $order->id . '.gif';

Pretty straightforward. Would be great that this package aids on the decoding of the image and just returning the file to save it on a default folder on a single line, like calling a class or something. Just an idea.

Awesome work, thank you.

@rawilk
Copy link
Owner

rawilk commented Nov 3, 2020

@Eggotron Thanks for the idea. That sounds like a pretty common use case, and I'll probably implement something like that into the package at some point. I'm not sure when I'll get a chance to work on it, but I'll definitely consider adding it.

@rawilk rawilk added the enhancement New feature or request label Nov 3, 2020
@rawilk
Copy link
Owner

rawilk commented Mar 4, 2021

This kind of functionality is now available in version 2.1.0.

To get the decoded image contents, just call: $package->getDecodedImageContent() on a package result.

To have this package store the image for you, you can call $package->storeLabel(). This will store the image on the configured file system disk, and will return the name of the file.

@rawilk rawilk closed this as completed Mar 4, 2021
@rawilk
Copy link
Owner

rawilk commented Mar 4, 2021

Also, sorry for not getting to this sooner; I just haven't had a chance to maintain this package until now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants