001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.imaging;
018
019import java.util.Objects;
020
021/**
022 * Enumerates known image formats.
023 */
024public enum ImageFormats implements ImageFormat {
025
026    // @formatter:off
027    UNKNOWN("bin"),
028    BMP("bmp", "dib"),
029    DCX("dcx"),
030    GIF("gif"),
031    ICNS("icns"),
032    ICO("ico"),
033    JBIG2("jbig2"),
034    JPEG("jpg", "jpeg"),
035    PAM("pam"),
036    PSD("psd"),
037    PBM("pbm"),
038    PGM("pgm"),
039    PNM("pnm"),
040    PPM("ppm"),
041    PCX("pcx", "pcc"),
042    PNG("png"),
043    RGBE("hdr", "pic"),
044    TGA("tga"),
045    TIFF("tif", "tiff"),
046    WBMP("wbmp"),
047    WEBP("webp"),
048    XBM("xbm"),
049    XPM("xpm");
050    // @formatter:on
051
052    private final String[] extensions;
053
054    ImageFormats(final String... extensions) {
055        this.extensions = Objects.requireNonNull(extensions);
056    }
057
058    @Override
059    public String getDefaultExtension() {
060        return extensions[0];
061    }
062
063    @Override
064    public String[] getExtensions() {
065        return this.extensions.clone();
066    }
067
068    @Override
069    public String getName() {
070        return name();
071    }
072}