- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from struct import Struct
|
|
|
|
from .constants import MIME_TYPE
|
|
from .image import BaseImageHeader
|
|
|
|
|
|
class Gif(BaseImageHeader):
|
|
"""Image header parser for GIF images.
|
|
|
|
Note that the GIF format does not support resolution (DPI) information. Both
|
|
horizontal and vertical DPI default to 72.
|
|
"""
|
|
|
|
@classmethod
|
|
def from_stream(cls, stream):
|
|
"""Return |Gif| instance having header properties parsed from GIF image in
|
|
`stream`."""
|
|
px_width, px_height = cls._dimensions_from_stream(stream)
|
|
return cls(px_width, px_height, 72, 72)
|
|
|
|
@property
|
|
def content_type(self):
|
|
"""MIME content type for this image, unconditionally `image/gif` for GIF
|
|
images."""
|
|
return MIME_TYPE.GIF
|
|
|
|
@property
|
|
def default_ext(self):
|
|
"""Default filename extension, always 'gif' for GIF images."""
|
|
return "gif"
|
|
|
|
@classmethod
|
|
def _dimensions_from_stream(cls, stream):
|
|
stream.seek(6)
|
|
bytes_ = stream.read(4)
|
|
struct = Struct("<HH")
|
|
px_width, px_height = struct.unpack(bytes_)
|
|
return px_width, px_height
|