java.lang.Object
org.miaixz.bus.extra.captcha.AbstractProvider
org.miaixz.bus.extra.captcha.provider.GifProvider
- All Implemented Interfaces:
Serializable,org.miaixz.bus.core.Provider,CaptchaProvider
Gif CAPTCHA Provider.
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Field Summary
Fields inherited from class org.miaixz.bus.extra.captcha.AbstractProvider
background, code, font, generator, height, imageBytes, interfereCount, textAlpha, width -
Constructor Summary
ConstructorsConstructorDescriptionGifProvider(int width, int height) Constructor to set CAPTCHA width and height.GifProvider(int width, int height, int codeCount) Constructor.GifProvider(int width, int height, int codeCount, int interfereCount) Constructor.GifProvider(int width, int height, int codeCount, int interfereCount, float sizeBaseHeight) Constructor.GifProvider(int width, int height, CodeStrategy generator, int interfereCount) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Creates a CAPTCHA.protected ImagecreateImage(String code) Creates the CAPTCHA image based on the generated code.setMaxColor(int maxColor) Sets the maximum color range.setMinColor(int minColor) Sets the minimum color range.setQuality(int quality) Sets the image's color quantization (conversion quality to the maximum 256 colors allowed by the GIF specification).setRepeat(int repeat) Sets the number of times the GIF frames should be played.Methods inherited from class org.miaixz.bus.extra.captcha.AbstractProvider
generateCode, get, getGenerator, getImage, getImageBase64, getImageBase64Data, getImageBytes, setBackground, setFont, setGenerator, setTextAlpha, verify, write, write, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.miaixz.bus.extra.captcha.CaptchaProvider
type
-
Constructor Details
-
GifProvider
public GifProvider(int width, int height) Constructor to set CAPTCHA width and height.- Parameters:
width- CAPTCHA width.height- CAPTCHA height.
-
GifProvider
public GifProvider(int width, int height, int codeCount) Constructor.- Parameters:
width- CAPTCHA width.height- CAPTCHA height.codeCount- Number of characters.
-
GifProvider
public GifProvider(int width, int height, int codeCount, int interfereCount) Constructor.- Parameters:
width- CAPTCHA width.height- CAPTCHA height.codeCount- Number of characters.interfereCount- Number of interfering elements.
-
GifProvider
Constructor.- Parameters:
width- Image width.height- Image height.generator- CAPTCHA code generator.interfereCount- Number of interfering elements.
-
GifProvider
public GifProvider(int width, int height, int codeCount, int interfereCount, float sizeBaseHeight) Constructor.- Parameters:
width- Image width.height- Image height.codeCount- Number of characters.interfereCount- Number of interfering elements.sizeBaseHeight- Font size as a multiplier of the height.
-
-
Method Details
-
setQuality
Sets the image's color quantization (conversion quality to the maximum 256 colors allowed by the GIF specification). Lower values (minimum = 1) produce better colors but are significantly slower to process. 10 is the default and produces good colors at a reasonable speed. Values greater than 20 do not produce significant improvements in speed.- Parameters:
quality- greater than 1.- Returns:
- this
-
setRepeat
Sets the number of times the GIF frames should be played. The default is 0, which means an infinite loop. Must be called before the first image is added.- Parameters:
repeat- must be greater than or equal to 0.- Returns:
- this
-
setMaxColor
Sets the maximum color range.- Parameters:
maxColor- the color.- Returns:
- this
-
setMinColor
Sets the minimum color range.- Parameters:
minColor- the color.- Returns:
- this
-
create
public void create()Description copied from interface:CaptchaProviderCreates a CAPTCHA. Implementations should generate both a random CAPTCHA string and a CAPTCHA image.- Specified by:
createin interfaceCaptchaProvider- Overrides:
createin classAbstractProvider
-
createImage
Description copied from class:AbstractProviderCreates the CAPTCHA image based on the generated code.- Specified by:
createImagein classAbstractProvider- Parameters:
code- The CAPTCHA code.- Returns:
- The CAPTCHA image.
-