CANVAS / SOURCE PIXELS
Crop first. Resize once.
Try an exact crop on generated test artwork. All coordinates refer to the original 640 × 480 pixels.
Preparing generated artwork…
What the code checks
Integer coordinates; positive dimensions; crop edges inside the source; output sides no larger than 4,096 and at most 4,000,000 output pixels. Height is calculated from the crop's aspect ratio. This is a crop-to-PNG teaching sample, not an SVG tracing engine.