def METHOD_NAME(app, url, image_file):
    from .app import App
    assert isinstance(app, App)
    if url and not os.path.isfile(image_file):
        try:
            img = app.crawler.download_image(url)
            os.makedirs(os.path.dirname(image_file), exist_ok=True)
            if img.mode not in ("L", "RGB", "YCbCr", "RGBX"):
                if img.mode == "RGBa":
                    #RGBa -> RGB isn't supported so we go through RGBA first
                    img.convert("RGBA").convert("RGB")
                else:
                    img = img.convert("RGB")
            img.save(image_file, "JPEG", optimized=True)
            logger.debug("Saved image: %s", image_file)
        finally:
            app.progress += 1