netbox icon indicating copy to clipboard operation
netbox copied to clipboard

HEIC image support

Open wreiske opened this issue 2 years ago • 5 comments

NetBox version

v2.9.8

Feature type

Change to existing functionality

Proposed functionality

Allow support for uploading heic format images to netbox devices.

Use case

Most modern devices (phones, tablets, etc) used by technicians to take photos in the data center / build rooms take pictures in the HEIC format, https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format

By supporting HEIC uploads, it can save a step required to first convert to a JPG or other currently supported file type.

Database changes

No response

External dependencies

Will require convert or imagemagick or another utility to convert the heic to jpg. This can be an optional depdency and only allow heic uploads if imagemagick is available.

wreiske avatar May 23 '22 18:05 wreiske

Support for HEIC is dependent upon Django's ImageField model field.

Will require convert or imagemagick or another utility to convert the heic to jpg. This can be an optional depdency and only allow heic uploads if imagemagick is available.

HEIC format support alone would not justify the introduction of either of these as a new dependency (optional or not). However, the pyheif-pillow-opener seems to add HEIC support for Pillow, which NetBox already uses.

jeremystretch avatar May 24 '22 13:05 jeremystretch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

github-actions[bot] avatar Jul 24 '22 04:07 github-actions[bot]

HEIC format support alone would not justify the introduction of either of these as a new dependency (optional or not). However, the pyheif-pillow-opener seems to add HEIC support for Pillow, which NetBox already uses.

As alternative, you can take a look at pillow-heif for that.

bigcat88 avatar Aug 09 '22 17:08 bigcat88

Would certainly appreciate to get that in. Having to convert the images every time is obnoxious. If you don't want to store th images as Geico just convert them on upload. That's a better user experience than denying people to use a widespread image format.

deridiot avatar Sep 03 '22 22:09 deridiot

looks like https://github.com/uploadcare/heif-image-plugin/ is the current plugin to use, however quick trial didn't allow uploading of heic image from Django...

arthanson avatar Sep 07 '22 19:09 arthanson

If someone still need this I can start making a PR.

bigcat88 avatar Oct 27 '22 09:10 bigcat88

This issue was initially accepted under the premise that merely introducing a dependent image processing library would be sufficient to achieve HEIF support, however as learned in PR #10774 that is unfortunately not the case.

I've discussed this with the other maintainers. Ideally, any support for new image formats should be delivered upstream in Django itself, as this functionality has nothing to do with NetBox itself. We'd also be willing to utilize a third-party replacement for the core ImageField which introduces this support if a strong argument can be made for doing so. However, this isn't something we're willing to own the maintenance of within NetBox itself.

For anyone interested in introducing support for HEIF images, I recommend submitting a feature request to the Django project.

jeremystretch avatar Nov 04 '22 13:11 jeremystretch

@jeremystretch , I respect your decision of maintainability, nevertheless, we still really need this functionality. Is there a plugin system or a way for us to "hook" into this image upload without needing to fork net box and run our own custom build of it?

Another thought is to force jpg or support formats on the file upload, which will allow mobile phones that default to heic to use jpg instead. Looking at the input box, it shows the following output:

<div class="row mb-3">
        <label for="id_image" class="form-label col col-md-3 text-lg-end required">
            Image
        </label>
        <div class="col col-md-9">
            <input type="file" name="image" accept="image/*" class="form-control" placeholder="Image" required="" id="id_image">
        </div>
    </div>

Changing the accept to something like accept="image/png, image/jpeg" and adding a capture tag might allow taking jpg photos right on the phone by clicking the file upload box. No conversion or extra support would need to be added on the server side.

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers

wreiske avatar Nov 04 '22 14:11 wreiske

Is there a plugin system or a way for us to "hook" into this image upload without needing to fork net box and run our own custom build of it?

As I said, if you would like to own the burden of creating, publishing, and maintaining a custom ImageField implementation that includes HEIF support as a separate Django app, we'll consider adopting it.

jeremystretch avatar Nov 04 '22 14:11 jeremystretch