    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
    019/**
    020 * Enum of known image formats.
    021 */
    022public enum ImageFormats implements ImageFormat {
    023    UNKNOWN(),
    024    BMP("bmp", "dib"),
    025    DCX("dcx"),
    026    GIF("gif"),
    027    ICNS("icns"),
    028    ICO("ico"),
    029    JBIG2(),
    030    JPEG("jpg", "jpeg"),
    031    PAM("pam"),
    032    PSD("psd"),
    033    PBM("pbm"),
    034    PGM("pgm"),
    035    PNM("pnm"),
    036    PPM("ppm"),
    037    PCX("pcx", "pcc"),
    038    PNG("png"),
    039    RGBE("hdr", "pic"),
    040    TGA(),
    041    TIFF("tif", "tiff"),
    042    WBMP("wbmp"),
    043    XBM("xbm"),
    044    XPM("xpm");
    045
    046    private final String[] extensions;
    047
    048    ImageFormats(String ...extensions) {
    049        this.extensions = extensions;
    050    }
    051
    052    @Override
    053    public String getName() {
    054        return name();
    055    }
    056
    057    @Override
    058    public String[] getExtensions() {
    059        return this.extensions.clone();
    060    }
    061
    062    @Override
    063    public String getDefaultExtension() {
    064        return this.extensions != null ? this.extensions[0] : null;
    065    }
    066}