Registry / storage / locator-image-utility

locator-image-utility

JSON →
library6.1.0jsnpmunverified

Utility module for handling image-related operations including regex patterns, validation schemas, and image processing. Version 6.1.0 is the current stable release. Designed specifically for use with the Hapi.js framework and CouchDB. Provides predefined image sizes and cropping/resizing functionality. Key differentiators: integrates tightly with Hapi request objects and CouchDB attachments.

npm install locator-image-utility
INSTALL
IMPORT
SIG · LOCATOR-IMAGE-UTIL
L
locator-image-utility
storagejavascriptv6.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

regex
const { regex } = require('locator-image-utility')
import { regex } from 'locator-image-utility'
Package uses CommonJS; ESM import may not work without transpilation.
validation
const { validation } = require('locator-image-utility')
const validation = require('locator-image-utility').validation
Destructuring is equivalent; both work but destructuring is cleaner.
image
const { image } = require('locator-image-utility')
const imageUtil = require('locator-image-utility').image
Destructuring is equivalent; both work.

Demonstrates creation of a Hapi server route that uses locator-image-utility for image upload validation and processing.

const { regex, validation, image } = require('locator-image-utility'); const Hapi = require('@hapi/hapi'); const server = Hapi.server({ port: 3000 }); server.route({ method: 'POST', path: '/upload', options: { payload: { output: 'stream', parse: true, allow: 'multipart/form-data', maxBytes: 10485760 }, validate: { payload: validation.basicImageSchema } }, handler: async (request, h) => { const imageProcessor = image.processor(request); const file = imageProcessor.createFileInformation('photo.png'); const attachmentData = imageProcessor.getAttachmentData(file.filename); const stream = imageProcessor.createCroppedStream(200, 200); return 'processed'; } }); await server.start(); console.log('Server running on %s', server.info.uri);
Debug
Known issues
gotchaThe image.processor() method requires a Hapi request object; passing an incorrect object will throw errors.
fix
Ensure the request argument is a valid Hapi request object from within a route handler.
affects: >0.0.0
gotchaThe package is designed for Hapi.js and CouchDB; using it outside this ecosystem may require additional setup.
fix
Consider alternative image processing libraries if not using Hapi/CouchDB.
affects: >0.0.0
deprecatedThe package uses old @hapi/hapi patterns; newer Hapi versions may require changes.
fix
Check compatibility with your Hapi version; update validation schemas if needed.
affects: >=6.0.0
Errors
Common errors & fixes
TypeError: image.processor is not a function
Incorrect import: using default import instead of named import.
fix
Use const { image } = require('locator-image-utility'); then image.processor(request).
Cannot find module 'locator-image-utility'
Module not installed or path incorrect.
fix
Run npm install locator-image-utility and ensure it's in node_modules.
Invalid payload: value must be a valid image
The uploaded file does not match basicImageSchema validation.
fix
Ensure the file is an image (PNG, JPG) and the request is multipart/form-data.
Upgrade
Version history
6.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
17
Resources
locator-image-utility — npm install locator-image-utility · libregistry