vs-image-viewerEnglish | 简体中文 A VS Code image viewer for PNG, JPG/JPEG, RAW/CFA, RGB-IR, and YUV. Files are grouped by extension in the left sidebar, images open in a zoomable editor, and parsing settings appear in the right Secondary Side Bar. Installation and usageRequires VS Code 1.106 or later, with support for extension view containers in the Secondary Side Bar.
The imported file list is saved per workspace; per-file settings are kept only for the current session. Extensions are normalized to lowercase for grouping; PNG, JPG, and JPEG have separate groups. Removing an entry closes its previews without deleting the source file. PNG/JPEG metadata is read-only; binary image parsing and display settings are editable. Filename inference on first openNew binary files initialize their properties from explicit case-insensitive tags in the filename. Tags can appear in any order, separated by
For example, Explicit fields override preset defaults. Missing or conflicting tags retain the default for that field; inferred invalid values are shown by the usual property validation. Without a container tag, RAW / CFA / RGB-IRUnknown extensions default to CFA. Use Image Format to switch to YUV. Width and height are editable and are inferred from names containing dimensions such as
Image reconstruction designJPEG preview edges and cornersJPEG previews enable JPEG Edge Repair by default. The corner icon in the left toolbar toggles between the repaired preview and the original browser decode. The pixel readout says Preview RGB8 when correction is applied. PNG, CFA and YUV keep their existing rendering paths; source files are never modified. media/jpeg-preview.js uses luminance gradients and eight rays at 45° intervals to find compatible color regions, including the interior of a corner. Each anchor must also pass a two-dimensional flatness check. A correction requires the decoded chroma to lie between two supported region colors while luminance identifies the pixel's side of the boundary. Only chroma is replaced; decoded luminance is preserved within RGB8 rounding. Conflicting hypotheses, clipping, low-contrast edges and insufficient evidence retain the original pixels. This is a conservative preview estimate, not recovery of information discarded by JPEG; it does not remove all compression artifacts or sharpen arbitrary textures. Its safeguards are independent of the CFA demosaic coefficient file. JPEG regression tests compare every pixel of independent JPEG decode snapshots with the original color bars and ColorChecker PNGs. They also cover eight corner orientations, clean edges, smooth ramps, fine texture, alpha and cancellation during file switches. Processing yields between row batches, and toggling always starts from the original decode. Data flow and responsibilitiesBinary preview separates storage interpretation, reconstruction and display. media/core.js reads samples using container size, pixel depth, alignment, byte order, offset and pitch. CFA values are normalized by black/white levels before interpolation. Exposure, gamma and RGB8 output conversion follow reconstruction and any RGB/IR blending; changing preview settings never writes back to the input.
The PNG/canvas preview is RGB8, while binary pixel inspection reports the original 4–32-bit integer sample. Color reconstruction errors are tested on decoded pixels before viewer zoom or browser scaling. Ordinary PNG/JPEG files use their encoded image rather than CFA reconstruction. Bayer reconstruction
References: IPOL's analysis of directional and residual demosaicing and the intra/inter-channel edge-preservation principles in Boccuto et al. (2024). The implementation is a lightweight adaptation, not a reproduction of the paper's iterative regularization solver. RGB-IR reconstruction orderA tile such as
IR values never substitute for green and do not participate in visible edge or corner confidence. IR-only extracts the original half-resolution plane; blending and side-by-side views retain their separate IR interpolation. All visible modes share the same reconstructed RGB. Corner model and reconstruction limitsCorner detection supports boundary rays at 0°, 45°, 90°, 135°, 180°, 225°, 270° and 315°, including 45°, 90° and 135° corner openings. Axis-aligned corners first use four 4×4 quadrants. Oblique candidates use a 12×12 window partitioned by a pair of boundary lines, with both assignments of samples lying exactly on a diagonal tested against the data. Each sector needs at least two samples of every visible channel. Three flat regions must agree on a background color, and the fourth must differ in at least two channels. A third distinct level in a visible channel rejects the oblique two-color model early. The decision uses raw samples, with no fixture names, known patch coordinates or reference colors in the decoder. For axis-aligned corners, Bayer correction covers a 6×6 neighborhood and RGB-IR covers the validated 8×8 neighborhood. Oblique correction covers 8×8 pixels within its 12×12 evidence window, accounting for the larger footprint of rotated interpolation. The precheck compares the center with its same-phase neighbors so an acute tip is detected even when both endpoints lie in the background. RGB-IR searches additional visible phases around an I anchor and excludes I from all model checks. Conflicting models at equal priority leave the existing estimate unchanged. Correction strength follows the direction/strength policy; An I position has no direct RGB sample. Equally supported RGB-IR corner positions prefer boundaries aligned with the original 2×2 cells, consistent with the straight-edge convention. This is an explicit reconstruction assumption: the true edge can remain ambiguous by one pixel. Flat-region fitting does not imply exact recovery of arbitrary textures or diagonal edges. No sensor-specific IR crosstalk correction, white balance, learned model or color calibration is applied. Conservative anti-alias refinement and display reductionRAW previews appear in two stages: fast local interpolation first, followed by the full-quality reconstruction. The replacement preserves zoom and pan; playback advances only after the final frame is ready. Green reconstruction now checks horizontal/vertical color-difference consistency over a 5×5 neighborhood before blending disagreeing candidates. The refinement fades with directional confidence and preserves low-disagreement areas, exact plateaus, evidence-backed corner neighborhoods and strong opposing red/blue transitions. It retains the eight-ray direction policies and every measured sample. Temporary filter planes use 256×256 tiles with an eight-pixel halo; translation tests cover tile seams. This is a conservative GBTF-inspired refinement, not a full ARI implementation. For RGB-IR, the virtual Bayer image carries a measured/reconstructed confidence mask. The new stage does not directly revise green at synthetic red/blue centers, and synthetic neighbors contribute less to its direction scores. IR values remain excluded. The optional Fit reduction integrates the covered source-pixel area into a separate display canvas, accounting for device pixel density and premultiplied alpha. Native pixels and inspection values remain unchanged. Integer zoom uses pixel-exact rendering; fractional enlargement uses smooth rendering. The full-frame benchmark, limitations and reproduction commands are in the quality report. Direction and strength coefficientsThe toolbar's sliders icon opens Eight independent ray groups cover 0°, 45°, 90°, 135°, 180°, 225°, 270°, 315° (clockwise in image coordinates: right, down-right, down, …). Detection compares like CFA phases two pixels apart and normalizes diagonal distances. Red/blue refinement also uses frozen green and opposite-chroma guides, keeping vector differences separate to avoid cancellation. Tied directions share their strategies. A gradient points across an edge; tangent preference favors samples along it. CFA sampling still constrains available interpolation candidates: horizontal/vertical green candidates, axis or diagonal red/blue candidates. Each
These coefficients affect the four standard Bayer patterns and the RGB-IR visible reconstruction path. Measured samples remain unchanged. They tune a lightweight edge-aware algorithm, not a learned or sensor-calibrated reconstruction. Full-frame regression criteriaColorChecker tests decode all six Bayer RGGB / RGB-IR RGBI variants: 12-bit in 16-bit containers, packed 12-bit and 16-bit. Each result is compared with the same PNG reference at the original 640×432 dimensions and default display/coefficient settings.
Bayer tests also cover phase, boundary parity, contrast reversal, diagonals, gradients and textures. RGB-IR tests cover all 24 tile permutations, IR-signal independence, whole-rectangle reconstruction, ambiguous corners, coefficient behavior and consistency across visible display modes. Original sample preservation remains a separate requirement. Directional corner tests cover all eight orientations, three opening angles, four Bayer phases and all 24 RGB-IR arrangements, plus high bit depths, reversed contrast, IR independence, coefficient control and transposition. Their 48×48 polygon images are checked in full (RGB8 MAE ≤ 1.5, maximum channel error ≤ 100), with a stricter ≤ 1 limit in the central 8×8 corner region. Distant diagonal edges retain the existing interpolation; these limits are separate from the unchanged ≤ 1 full-frame ColorChecker requirement. Run the reconstruction regressions with:
YUV
Presets include I420, YV12, NV12, NV21, I422, NV16, NV61, YUYV, UYVY, I444, NV24, NV42, P010, P012, and P016. Supported matrices are BT.601, BT.709, and BT.2020, with full or limited range. Chroma uses nearest-neighbor upsampling. Hover over Color Matrix or Range for one second to read the documentation. Keyboard focus also opens it; Esc closes it. The help explains matrix selection, 8/10-bit ranges, and the effects of incorrect settings. BT.2020 uses the non-constant-luminance matrix only, without HDR transfer-function decoding or display gamut conversion. Display Channel offers color, luma-only, and chroma-only views. Luma ignores U/V; chroma displays U/V colors at a fixed 50% luma. Display selection does not change frame sizes or boundaries. Chroma is unavailable for 400 images. File Contents selects the actual planes present: full YUV, Y only, or UV only. Always enter the full image dimensions: a 320×240 image with 420 UV data contains 160×120 U/V sample pairs. Standalone planes support pixel depth, container size, offsets, pitches, and sequences; frame sizes count only the planes present. For odd dimensions, chroma dimensions round up. The last packed 422 pixel pair still occupies four samples. For example, an 8-bit 3×3 420 frame contains 9 bytes of Y and 4 bytes each of U and V, totaling 17 bytes. Pixel depth and storageCFA and YUV samples support unsigned 4–32-bit integers.
Pixel Depth, Container Size, and Bit Alignment have hover documentation. Hover over a label for about one second, or focus it using the keyboard; press Esc to close the help. Bit packing is a per-row contiguous stream, not MIPI CSI-2 RAW10/12/14 grouped packing. v210, signed or floating-point samples, compressed RAW, and vendor container formats require conversion before opening. Reading and interactionThe viewer reads one frame starting at Read Offset, in bytes. Insufficient data produces inline errors instead of drawing an incomplete frame. Single-frame mode ignores and reports trailing bytes. Read Offset has hover and keyboard-accessible documentation. Image sequencesPlayback controls float over the image with a translucent glass background. They fade out after 3 seconds without pointer or keyboard activity, while playback continues. Moving within an image preview or the properties panel restores them; returning focus to VS Code also restores them. Hovering anywhere over the playback bar, dragging the timeline, or editing frame/FPS values keeps the controls visible. The three-second countdown resumes after the pointer leaves and editing ends. The extension cannot observe every mouse movement in native VS Code areas such as Explorer through the public API. RAW/CFA, RGB-IR, and YUV files can contain consecutive frames with identical dimensions and layouts. Playback controls appear when the available data after the offset is strictly greater than two frame sizes. Exactly two frames remain in single-frame mode; two frames plus a partial tail allow browsing the two complete frames.
Playback reuses a decoder worker, requests one frame at a time, and retains the latest frame's raw bytes for pixel inspection. It does not cache entire sequences or queue a backlog of decoding work. FPS is a target maximum; slow decoding reduces playback speed without skipping frames. Local binary files use seek-based range reads and worker decoding. Virtual files use the VS Code filesystem API. The extension imposes no fixed image-dimension, pixel-count or file-size limit. Actual capacity depends on available memory and the runtime/browser. Side-by-side RGB/IR doubles the output width. Local binary files read only the selected frame; virtual files require a full-file read before selecting the frame. Invalid or numerically imprecise dimensions and ranges are still rejected, and insufficient file data is reported inline. Preview controlsThe glass toolbar uses compact line icons. Keep the pointer still over an icon for two seconds to see its label. Moving, clicking, or dragging dismisses the tooltip; keyboard focus also provides help, and Esc closes it.
Development and verificationLocalizationThe extension supports English and Simplified Chinese and follows the VS Code display language. Unsupported languages fall back to English. Changing the display language and restarting VS Code updates commands, properties, hover help, toolbar labels, and errors. Strings use stable resource keys, similar to Android string resources:
For example, code calls To add a language, copy Preview either language at CommandsRequires Node.js 22 or later. There are no external runtime dependencies.
Commands can also be invoked directly, for example
Extension-host integration tests live in Fixtures
Added complex scenes: traffic intersection, wildlife, and football, each at 1536 × 1024, with 12-bit-in-16, packed 12-bit and 16-bit CFA variants (nine RAWs) and three RGB reference PNGs. Explicit filenames auto-select the decoding settings. See fixture catalog and reproduction instructions; regenerate with Added a 640 × 432 ColorChecker 24 IQ chart with a PNG reference and six Bayer RGGB / RGB-IR RGBI RAW variants (12-in-16, packed 12-bit and 16-bit). It contains a 6 × 4 patch grid including six gray levels, using the published 2005 sRGB reference palette. Run Tests cover pixel depths, container sizes, byte order, alignment, YUV layouts, odd dimensions, RGB-IR views, validation, offsets, worker decoding, PNG encoding, sequence boundaries, seeking, playback timing, FPS changes, and toolbar configuration synchronization. Disk changes are tracked for imported images, including files outside the workspace. Selecting an existing image or returning to the VS Code window checks its displayed source data and offers Reload / Keep Current Image only when it differs. RAW/YUV compares the displayed frame range, so changes to other frames or appended data do not reload the current image. Timestamp-only changes do not prompt. Unavailable files preserve the current image; accepting Reload rechecks the data in case it was restored while the prompt was open. |