ComfyUI-PepeUtils
Small utility nodes for ComfyUI including Anime PromptGen, Load Image Cropped, Pepe Scale Image By, and Stride Scale Size.
ComfyUI-PepeUtils
Small utility nodes for ComfyUI.
Currently included:
- Anime PromptGen - generates anime prompt text with the FredZhang7 GPT-2 prompt generator or a compatible local GGUF file through Transformers.
- Load Image Cropped - loads an image and returns a cropped image + mask, with an interactive crop preview in the ComfyUI frontend.
- Pepe Paste Image - pastes a clipboard image into a selected node and keeps it only in ComfyUI's temporary storage.
- Pepe Resize Image - resizes, crops, pads, or pillarboxes images with automatic Lanczos upscale and Pepe Bicubic Sharper downscale selection.
- Pepe Scale Image By - scales images with a Photoshop Bicubic Sharper style approximation based on configurable cubic resampling.
- Stride Scale Size - computes width/height snapped to a chosen stride after scaling.
Node Screenshots

Installation
Option 1: Git clone
Clone this repository into your ComfyUI/custom_nodes directory:
git clone https://github.com/Pepehoschi/ComfyUI-PepeUtils.git
Option 2: Download ZIP
Download this repository as a ZIP, extract it, and place the folder here:
ComfyUI/custom_nodes/ComfyUI-PepeUtils
Then restart ComfyUI.
Requirements
No extra setup is currently documented beyond a normal ComfyUI installation.
This node relies on libraries that are typically already present in ComfyUI environments:
torchnumpyPillow
The Anime PromptGen node also needs:
transformersggufwhen loading.gguffiles through Transformers
Place local GGUF models in one of these folders:
ComfyUI/models/gguf
ComfyUI/models/llm_gguf
ComfyUI/models/LLM/GGUF
After restarting ComfyUI, files in that folder appear in the gguf_model dropdown. You can also paste an absolute .gguf path into gguf_file_path.
Included Nodes
Anime PromptGen
Category: utils/text
Inputs:
promptmodel_id_or_pathtokenizer_id_or_pathgguf_modelgguf_file_pathmax_lengthnum_return_sequencesdo_samplerepetition_penaltytemperaturetop_kearly_stoppingseeddtypedevicelocal_files_onlystrip_input_prompt
Outputs:
promptsfirst_prompt
What it does:
- Wraps the Hugging Face text-generation pipeline.
- Exposes the generation arguments from the original
outs = nlp(...)snippet as node widgets. - Loads the normal Hugging Face model by default.
- Can load a compatible local
.ggufmodel with Transformers usinggguf_file.
Notes:
- Transformers loads GGUF checkpoints by dequantizing them into PyTorch weights, so memory use is closer to the selected
dtypethan to the GGUF file size. - For GGUF workflows, the node first tries tokenizer metadata from the GGUF or adjacent files before falling back to
tokenizer_id_or_path. - If a custom node changes Hugging Face hub settings and you see requests to mirrors such as
hf-mirror.com, enablelocal_files_onlyor settokenizer_id_or_pathto a local tokenizer folder.
Load Image Cropped
Category: image
Inputs:
image
Outputs:
imagemaskwidthheight
What it does:
- Loads an input image from ComfyUI.
- Lets you define a crop rectangle.
- Returns the cropped image and cropped mask.
- Also returns the crop width and height as integers.
Frontend behavior:
- Includes an interactive crop preview.
- Internal crop coordinates are updated from the preview.
- Supports dragging a file onto the node to upload/select an image.
- Includes a Clear Crop context-menu action.
Notes:
- If the crop is invalid or empty, it falls back to the full image.
- Crop coordinates are clamped to the image bounds.
Pepe Paste Image
Category: image
Outputs:
imagemask
What it does:
- Select the node and press
Ctrl+Vto paste an image from the system clipboard. - Alternatively, click Paste image from clipboard.
- Shows a preview and the pasted image dimensions.
- Uploads clipboard images only to
ComfyUI/temp/pepeutils/paste-image.
Notes:
- Pasted files are removed by ComfyUI when it starts and when it shuts down normally.
- A saved workflow retains the temporary filename, not the image itself. Paste the image again after restarting ComfyUI.
- The clipboard button depends on browser clipboard permission.
Ctrl+Vremains available when direct clipboard access is unavailable. - Exactly one Pepe Paste Image node must be selected for the
Ctrl+Vshortcut.
Pepe Scale Image By
Category: utils/image
Inputs:
imagescale_bysnap_to_stridestridesnap_mode(nearest,down,up)clamp_intermediate
Outputs:
imagewidthheight
What it does:
- Scales a ComfyUI image batch by
scale_by. - Uses a NumPy separable resampler approximating Photoshop CS5.1 Bicubic Sharper behavior from Jason Summers' ResampleScope notes.
- For each axis, applies an integrated box prepass when scale is below
0.25, then a cubic pass withB=0,blur=1.05, and scale-dependentC. - Processes X first, then Y, and clamps after cubic passes when
clamp_intermediateis enabled. - Uses a box blur of
0.33and source-space phase0.3999for the large-downscale prepass. - Uses cubic filter scale derived from the active cubic pass: direct downscales use
scale; large downscales below0.25prebox to4x target, so the final cubic pass uses0.25. - Equivalent cubic filter scale rule:
max(scale, 0.25).
Notes:
- This is not guaranteed to be pixel-identical to Photoshop. Boundary handling, rounding, and exact clamping behavior are reverse-engineered approximations.
- Manual ring-pattern tests matched Photoshop closely from scale
0.3upward with this derived math. Below0.25, minor differences remain around Photoshop's exact box prepass/crop behavior. - Very large images or batches may be slower than ComfyUI's built-in GPU scaling because this node runs the custom resampler on CPU.
Pepe Resize Image
Category: utils/image
Inputs:
imagewidthheightkeep_proportion(stretch,resize,pad,pad_edge,pad_edge_pixel,crop,pillarbox_blur,total_pixels)pad_color_rpad_color_gpad_color_bcrop_position(center,top,bottom,left,right)divisible_bymask(optional)
Outputs:
imagewidthheightmask
What it does:
- Provides KJNodes-style resize, pad, crop, pillarbox, and total-pixel geometry modes.
- Automatically uses Lanczos when enlarging.
- Automatically uses the existing Pepe Photoshop-style Bicubic Sharper path when reducing.
- Handles mixed-axis
stretchby shrinking first, then enlarging. - Applies the same geometry to optional masks with mask-safe bilinear interpolation.
- Aligns final dimensions downward to
divisible_by.
Notes:
- Width or height may be
0; missing dimensions are derived from the source aspect ratio. pad_edgefills padding from average edge colors.pad_edge_pixelextends actual edge pixels.pillarbox_bluruses a blurred cover background plus a sharp fitted foreground.
Stride Scale Size
Category: utils/math
Inputs:
image_widthimage_heightrescale_bystridemode(down,up,nearest)side_selector(shortest,longest)clamp_rescale_min_1
Outputs:
scaled_widthscaled_heightchosen_side
What it does:
- Scales an input size.
- Snaps the result to a stride.
- Returns the scaled width, height, and either the shortest or longest side.
Folder Structure
ComfyUI-PepeUtils/
├─ LICENSE
├─ __init__.py
├─ AnimePromptGen.py
├─ assets/
│ └─ nodes.png
├─ LoadImageCropped.py
├─ PasteImage.py
├─ PepeResizeImage.py
├─ PepeScaleImageBy.py
├─ StrideScaleSize.py
├─ examples/
│ └─ minimal_workflow.json
└─ web/
├─ load_image_cropped.js
└─ paste_image.js
Example Workflow
A minimal example workflow is included at:
It places both included PepeUtils nodes into a small ComfyUI workflow:
LoadImageCroppedStrideScaleSize
Notes:
- Set the image filename in the workflow to a file that exists in your ComfyUI input folder.
- The two nodes are intentionally shown as simple standalone examples;
StrideScaleSizeuses numeric widget values rather than being wired from another node.
Development Notes
Files that should not be published as source artifacts are ignored in .gitignore, including:
__pycache__/*.pyc.omx/
License
GNU GPL v3