Comment on Fun fact: you can't upload this image on piefed.social

irelephant@lemmy.dbzer0.com ⁨1⁩ ⁨week⁩ ago

The snippet that does this is:

if site.enable_chan_image_filter:
                # Do not allow fascist meme content
                try:
                    if '.avif' in uploaded_file.filename:
                        import pillow_avif  # NOQA
                    image_text = pytesseract.image_to_string(Image.open(BytesIO(uploaded_file.read())).convert('L'))
                except FileNotFoundError:
                    image_text = ''
                except UnidentifiedImageError:
                    image_text = ''

                if 'Anonymous' in image_text and (
                        'No.' in image_text or ' N0' in image_text):  # chan posts usually contain the text 'Anonymous' and ' No.12345'
                    self.image_file.errors.append(
                        "This image is an invalid file type.")  # deliberately misleading error message
                    current_user.reputation -= 1
                    db.session.commit()
                    return False

(Link in the post body)

source
Sort:hotnewtop