A user taps "upload" on an iPhone and your server receives IMG_4211.HEIC. Your image CDN does not render it, the PDF library you use for invoices rejects it, and Chrome on Windows shows a broken icon. Meanwhile your marketing site is full of PNG screenshots weighing 900 KB each, and a designer has just handed you the new logo as an SVG for a mobile app that only accepts raster icons.
These are the same problem: a file in format A has to become format B, often at a different size. The conversion itself is the easy part. The judgment is in choosing B, sending the file in a way the API accepts, and not losing the output afterwards.
Choose the target format before you write any code
Most format mistakes are made before the first request: someone converts everything to PNG "to be safe" and ships pages three times heavier than they need to be, or converts a logo to JPEG and gets grey fringes around the text. Pick the target from what the image is and where it is going.
| Format | Good for | Weak at | Notes |
|---|---|---|---|
| JPEG | Photos, anything with gradients and noise | Sharp edges, text, transparency | Lossy. Every re-save loses a little more. Universally supported. |
| PNG | Screenshots, UI, logos, anything needing transparency | Photos (files get huge) | Lossless. Safe for text and flat colour. |
| WebP | Photos and graphics on the web | Old software, some email clients, office tools | Lossy or lossless, usually much smaller than JPEG or PNG at similar quality. |
| AVIF | Web photos where size matters most | Tooling support, encoding speed | Often smaller still than WebP. |
| HEIC/HEIF | Storage on Apple devices | Almost everywhere else | What iPhones save by default. Convert on arrival. |
| GIF | Legacy animations | Everything else | 256 colours per frame. |
| SVG | Logos, icons, diagrams | Photos; anything that must be a bitmap | Vector, scales without blur, but it is code, not pixels. |
Two rules cover most real decisions. First, photographs go lossy, graphics go lossless: JPEG or WebP for a camera image, PNG for a screenshot or a logo with transparency. Second, the destination decides, not the source. A web page can take WebP; an email to an unknown client, a PDF generator, or a government upload form usually wants JPEG or PNG.
One catalog fact shapes the table: the converters read AVIF but do not write it. The output formats on Image Converter are png, jpg, webp, gif, tiff, bmp and pdf. If you need AVIF on the way out, WebP is the closest format you can produce here.
A support form accepts screenshots that users annotate with red arrows and text. Your app stores them for agents to read. Which target format is the right default?
Answer the check above to continue.
Rasterising SVG for places that need pixels
SVG is the right master format for logos and icons, and the wrong delivery format surprisingly often: app stores want PNG icons at fixed sizes, many email clients will not display SVG, and Open Graph images must be raster.
There is also a security reason to rasterise. An SVG file is XML that a browser executes, and it can contain scripts and external references. If users can upload SVG avatars or logos and you serve those files from your own domain, you are serving them code. Converting user-supplied SVG to PNG on upload, and serving only the PNG, turns a document into pixels and closes that hole.
svgconverter accepts only SVG and writes png, jpg or webp. Use maxWidth to set the output size: vector input has no "real" pixel size, so pick the largest size you will display and let smaller sizes scale down from that.
The catalog also shows the vector-or-raster choice from the other side. Country Flags hands you a flag as either format. Ask for svg and you get a file that stays sharp at any size; omit format and you get PNG.
curl "https://api.apiverve.com/v1/countryflags?country=JP&format=svg" \
-H "x-api-key: YOUR_API_KEY"data.format is svg and downloadUrl ends in .svg. Choosing the format is a premium option; without it you get png.
If you are drawing a flag in a 24-pixel table cell, the PNG is simpler. If the same flag appears on a retina hero banner and in a printed PDF, the SVG is one file that serves both, and you rasterise it yourself only for destinations that cannot take vectors.
Quality, size and the link that expires
quality (1 to 100, default 90) only matters for jpg and webp. Ninety is a conservative default that favours fidelity. For photos displayed on the web, 75 to 85 usually halves the file again with no difference anyone will notice. For product photos where customers zoom in, stay near 90. Do not reconvert a JPEG to JPEG repeatedly; each pass loses detail. Convert from the original every time you need a new size.
If you need to know how much a setting saves and outputSize is not on your plan, measure it yourself: the byte length of what you download from downloadURL is the real number.
Every successful conversion returns downloadURL and expires. The link is temporary. On these endpoints expires is a Unix timestamp in milliseconds, about two days after the call. Treat it as a pickup slip, not storage:
- Download the bytes immediately after the call returns.
- Write them to storage you own.
- Store your own URL in the database, never the
downloadURL.
A downloadURL saved to a database works in every test and then breaks every image in production two days later. That is the single most common bug in image pipelines built on any conversion service.
You store `data.downloadURL` in your products table as the image URL. What happens?
What this costs and when to skip the API
Each conversion is 10 credits. That is cheap per image and adds up across a bulk backfill, so a few habits keep it sensible: convert once on upload, never on every request; key your stored output on the source file's hash so a re-upload of the same photo reuses the existing result; and skip the call entirely when the input is already in the target format and within the size you need.
Formats are now under control: you can take anything a phone or a designer sends you and turn it into what your pages, PDFs and emails need. Next you will go the other way and create images that never existed as files at all, by rendering HTML and Markdown into social cards and receipts: Render HTML and Markdown to images.